Skip to content

Commit

Permalink
Merge pull request Expensify#54790 from FitseTLT/fix-displaying-user-…
Browse files Browse the repository at this point in the history
…to-invite-as-recent-chat

Fix - Search- New participant/email is shown as recent chat when found via search
  • Loading branch information
rlinoz authored Jan 14, 2025
2 parents e9fc8b3 + 0be72a5 commit 4365558
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/Search/SearchRouter/SearchRouterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ function SearchRouterList(
*/
const filterOptions = useFastSearchFromOptions(searchOptions, {includeUserToInvite: true});

const recentReportsOptions = useMemo(() => {
const [recentReportsOptions, userToInvite] = useMemo(() => {
if (autocompleteQueryValue.trim() === '') {
return searchOptions.recentReports.slice(0, 20);
return [searchOptions.recentReports.slice(0, 20)];
}

Timing.start(CONST.TIMING.SEARCH_FILTER_OPTIONS);
Expand All @@ -406,10 +406,7 @@ function SearchRouterList(
Timing.end(CONST.TIMING.SEARCH_FILTER_OPTIONS);

const reportOptions: OptionData[] = [...orderedOptions.recentReports, ...orderedOptions.personalDetails];
if (filteredOptions.userToInvite) {
reportOptions.push(filteredOptions.userToInvite);
}
return reportOptions.slice(0, 20);
return [reportOptions.slice(0, 20), filteredOptions.userToInvite];
}, [autocompleteQueryValue, filterOptions, searchOptions]);

useEffect(() => {
Expand All @@ -435,6 +432,11 @@ function SearchRouterList(
sections.push({title: translate('search.recentSearches'), data: recentSearchesData});
}

if (userToInvite) {
const styledUserToInvite = [userToInvite]?.map((item) => ({...item, pressableStyle: styles.br2, wrapperStyle: [styles.pr3, styles.pl3]}));
sections.push({title: undefined, data: styledUserToInvite});
}

const styledRecentReports = recentReportsOptions.map((item) => ({...item, pressableStyle: styles.br2, wrapperStyle: [styles.pr3, styles.pl3]}));
sections.push({title: translate('search.recentChats'), data: styledRecentReports});

Expand Down

0 comments on commit 4365558

Please sign in to comment.