Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up - Fix - remove recent chats header on Search Router List when searching #55784

Merged
Merged
Changes from all commits
Commits
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
16 changes: 7 additions & 9 deletions src/components/Search/SearchRouter/SearchRouterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ function SearchRouterList(
*/
const filterOptions = useFastSearchFromOptions(searchOptions, {includeUserToInvite: true});

const [recentReportsOptions, userToInvite] = useMemo(() => {
const recentReportsOptions = 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 @@ -410,7 +410,10 @@ function SearchRouterList(
Timing.end(CONST.TIMING.SEARCH_FILTER_OPTIONS);

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

useEffect(() => {
Expand All @@ -436,13 +439,8 @@ 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});
sections.push({title: autocompleteQueryValue.trim() === '' ? translate('search.recentChats') : undefined, data: styledRecentReports});

if (autocompleteSuggestions.length > 0) {
const autocompleteData = autocompleteSuggestions.map(({filterKey, text, autocompleteID, mapKey}) => {
Expand Down
Loading