Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4509a2f
add contact options lazy loading
jmgraa Jul 27, 2026
698ef39
move lazy loading to separate component
jmgraa Jul 27, 2026
f71a45e
move policy, tag, and archive lookups inside createFullOption
jmgraa Jul 27, 2026
ff17fea
add tests for lazy loading and hydration of contactOptions
jmgraa Jul 27, 2026
0e9b5b0
add eslint rule for translateLocal in lazyContactOptions
jmgraa Jul 27, 2026
67eb436
add test to ensure createOption and lazy shell remain in sync for fil…
jmgraa Jul 27, 2026
1f2bdeb
remove lazyContactOptions and introduce lazyHydrationData
jmgraa Jul 27, 2026
dd91862
empty commit to trigger ci
jmgraa Jul 27, 2026
ea82e46
refactor lazy hydration logic to utilize a shared context for persona…
jmgraa Jul 27, 2026
7a879c0
unify text generation and streamline lazy hydration context
jmgraa Jul 28, 2026
57e8c83
add GetPersonalDetailOptionTextProps
jmgraa Jul 29, 2026
50f1ebc
call getPersonalDetailOptionText with object arguments
jmgraa Jul 29, 2026
cee50f0
skip phone formatting for a field no shell consumer reads
jmgraa Jul 29, 2026
2575190
stop building contacts for the search "in" filter
jmgraa Jul 29, 2026
c0852be
document what includeP2P costs on the option list
jmgraa Jul 29, 2026
deeb34d
memoize contact hydration per shell
jmgraa Jul 29, 2026
6ac089c
type contact shells so display fields cannot be read unhydrated
jmgraa Jul 29, 2026
d82d283
Merge remote-tracking branch 'upstream' into jmgraa/lazy-contact-sear…
jmgraa Aug 3, 2026
0de78f9
remove alternateText from LazyPersonalDetailOption
jmgraa Aug 3, 2026
3e5f7bc
clarify compile error handling of hydrateLazyPersonalDetailOption
jmgraa Aug 3, 2026
f5bc963
test lazy hydration of participant options
jmgraa Aug 3, 2026
f5d4398
fix ESLint seatbelt configuration of translateLocal
jmgraa Aug 3, 2026
7db05fc
Merge remote-tracking branch 'upstream' into jmgraa/lazy-contact-sear…
jmgraa Aug 4, 2026
a4ea4eb
include conciergeReportID parameter
jmgraa Aug 4, 2026
19df340
require includeP2P parameter
jmgraa Aug 6, 2026
0dadcd6
improve type safety and support direct hydration
jmgraa Aug 6, 2026
3b5b6d2
bound NewChatPage contact hydration
jmgraa Aug 6, 2026
54044af
type filter/rank helpers structurally and drop the deprecated transla…
jmgraa Aug 6, 2026
7ef0030
update useGroupChatDraftParticipantSync to strip the hydration flag f…
jmgraa Aug 6, 2026
be8e0cc
update comments for clarity
jmgraa Aug 7, 2026
d79acd8
cleanup lazy contact build
jmgraa Aug 7, 2026
308e690
reuse filterReports logic for filterSelfDMChat
jmgraa Aug 10, 2026
b8c7fc9
add tests for preserving selected and bold marks
jmgraa Aug 10, 2026
4e7b4c3
remove unused PersonalDetailShell
jmgraa Aug 10, 2026
59b75cc
fix spell errors
jmgraa Aug 10, 2026
a41ab6a
support diacritics and zero-width characters in search terms
jmgraa Aug 10, 2026
1965838
swap conditions in isSearchTermsFound
jmgraa Aug 10, 2026
7fe6e0a
shorten comments
jmgraa Aug 11, 2026
856abaf
rename hydrateLazyPersonalDetailOption and hydrateContactOption
jmgraa Aug 11, 2026
8e9b127
apply getValidOptionsConfig based on defined contexts
jmgraa Aug 11, 2026
9742441
Merge remote-tracking branch 'upstream' into jmgraa/lazy-contact-sear…
jmgraa Aug 11, 2026
7b52b2a
remove deferred hydration logic and simplify getValidOptions function
jmgraa Aug 11, 2026
2b14d18
remove unused PersonalDetailFilterRankFields type export
jmgraa Aug 11, 2026
7476a90
refactor comment
jmgraa Aug 11, 2026
768baff
fix whitespaces
jmgraa Aug 11, 2026
0717515
fix comments formatting
jmgraa Aug 13, 2026
d24d01e
Merge remote-tracking branch 'upstream' into jmgraa/lazy-contact-sear…
jmgraa Aug 13, 2026
f6683a2
run fmt
jmgraa Aug 13, 2026
768bcd7
empty commit to trigger ci
jmgraa Aug 13, 2026
b7b99c9
Merge remote-tracking branch 'upstream' into jmgraa/lazy-contact-sear…
jmgraa Aug 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Search/FilterComponents/InSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
const {options, isLoading} = useFilteredOptions({
enabled: ready,
isSearching: !!debouncedSearchTerm.trim(),
// The sections below read recentReports and never personalDetails, so contacts would never reach the list.
includeP2P: false,
});

const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ function SearchAutocompleteList({
} = useFilteredOptions({
enabled: true,
isSearching: !!autocompleteQueryValue.trim(),
includeP2P: true,
// The empty-query state renders only recent searches and recent reports (no standalone contacts),
// so contacts can be deferred until the user types a query.
deferContactsUntilSearch: true,
Expand Down
9 changes: 5 additions & 4 deletions src/hooks/useFilteredOptions.ts
Comment thread
jmgraa marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type UseFilteredOptionsConfig = {
maxRecentReports?: number;
/** Whether the hook should be enabled (default: true) */
enabled?: boolean;
/** Whether to include P2P personal details (default: true) */
includeP2P?: boolean;
/** Whether to build contact shells. This value must match the downstream `includeP2P` value. */
includeP2P: boolean;
/** Number of reports to load per batch when paginating (default: 100) */
batchSize?: number;
/** Whether to enable dynamic loading/pagination (default: true) */
Expand Down Expand Up @@ -68,15 +68,16 @@ type UseFilteredOptionsResult = {
* const {options, isLoading} = useFilteredOptions({
* maxRecentReports: 500,
* enabled: didScreenTransitionEnd,
* includeP2P: true,
* });
*
* <SelectionList
* sections={isLoading ? [] : sections}
* shouldShowLoadingPlaceholder={isLoading}
* />
*/
function useFilteredOptions(config: UseFilteredOptionsConfig = {}): UseFilteredOptionsResult {
const {maxRecentReports = 500, enabled = true, includeP2P = true, batchSize = 100, isSearching = false, deferContactsUntilSearch = false} = config;
function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOptionsResult {
const {maxRecentReports = 500, enabled = true, includeP2P, batchSize = 100, isSearching = false, deferContactsUntilSearch = false} = config;

const [reportsLimit, setReportsLimit] = useState(maxRecentReports);

Expand Down
21 changes: 17 additions & 4 deletions src/hooks/useSearchSelector/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ type UseSearchSelectorReturn = {

const emptyOptionList: OptionList = {reports: [], personalDetails: []};

const CONTEXTS_APPLYING_GET_VALID_OPTIONS_CONFIG: ReadonlySet<SearchSelectorContext> = new Set([
CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_GENERAL,
CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_ATTENDEES,
]);

const doOptionsMatch = (option1: OptionData, option2: OptionData) => {
return (
(option1.accountID && option1.accountID === option2.accountID) || // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- this is boolean comparison
Expand Down Expand Up @@ -212,6 +217,12 @@ function useSearchSelectorBase({

// Searching bypasses the recent-reports pre-filter so a typed query can still match reports outside the top 500 most recently active ones.
const isSearchingOptions = !!debouncedSearchTerm.trim();

// Keep option-list contact building aligned with downstream includeP2P filtering.
const appliesGetValidOptionsConfig = CONTEXTS_APPLYING_GET_VALID_OPTIONS_CONFIG.has(searchContext);
const includeP2P = !appliesGetValidOptionsConfig || (getValidOptionsConfig.includeP2P ?? true);
const appliedGetValidOptionsConfig = appliesGetValidOptionsConfig ? getValidOptionsConfig : CONST.EMPTY_OBJECT;

const {
options: filteredOptions,
isLoading: isLoadingOptions,
Expand All @@ -220,6 +231,7 @@ function useSearchSelectorBase({
} = useFilteredOptions({
enabled: shouldInitialize,
isSearching: isSearchingOptions,
includeP2P,
batchSize: maxResultsPerPage,
});
const areOptionsInitialized = !isLoadingOptions;
Expand All @@ -229,7 +241,6 @@ function useSearchSelectorBase({
if (!contactOptions?.length || !areOptionsInitialized) {
return defaultOptions;
}

// Imported contacts get a generated accountID, so one sharing a login with a real Onyx user would show a duplicate
// row and be treated as a new invite. Track already-represented logins and drop contacts whose login is present.
const existingLogins = new Set<string>();
Expand Down Expand Up @@ -261,7 +272,8 @@ function useSearchSelectorBase({

return {
...defaultOptions,
personalDetails: defaultOptions.personalDetails.concat(dedupedContactOptions),
// Imported contacts are already hydrated.
personalDetails: defaultOptions.personalDetails.concat(dedupedContactOptions.map((contact) => ({...contact, isHydrated: true as const}))),
};
})();

Expand Down Expand Up @@ -328,7 +340,7 @@ function useSearchSelectorBase({
allPolicyTags,
sortedActions,
isTrackIntentUser,
...getValidOptionsConfig,
...appliedGetValidOptionsConfig,
},
translate,
);
Expand Down Expand Up @@ -365,6 +377,7 @@ function useSearchSelectorBase({
allPolicyTags,
sortedActions,
isTrackIntentUser,
...appliedGetValidOptionsConfig,
},
translate,
);
Expand Down Expand Up @@ -399,7 +412,7 @@ function useSearchSelectorBase({
allPolicyTags,
sortedActions,
isTrackIntentUser,
...getValidOptionsConfig,
...appliedGetValidOptionsConfig,
},
translate,
);
Expand Down
Loading
Loading