diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 7337ab4dc359..b63b14a4eeec 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -221,7 +221,7 @@ type PreviewConfig = {showChatPreviewLine?: boolean; forcePolicyNamePreview?: bo type FilterOptionsConfig = Pick< GetOptionsConfig, 'sortByReportTypeInSearch' | 'canInviteUser' | 'betas' | 'selectedOptions' | 'excludeUnknownUsers' | 'excludeLogins' | 'maxRecentReportsToShow' -> & {preferChatroomsOverThreads?: boolean}; +> & {preferChatroomsOverThreads?: boolean; includeChatRoomsByParticipants?: boolean}; type HasText = { text?: string; @@ -2450,7 +2450,15 @@ function getFirstKeyForList(data?: Option[] | null) { * Filters options based on the search input value */ function filterOptions(options: Options, searchInputValue: string, config?: FilterOptionsConfig): Options { - const {sortByReportTypeInSearch = false, canInviteUser = true, betas = [], maxRecentReportsToShow = 0, excludeLogins = [], preferChatroomsOverThreads = false} = config ?? {}; + const { + sortByReportTypeInSearch = false, + canInviteUser = true, + betas = [], + maxRecentReportsToShow = 0, + excludeLogins = [], + preferChatroomsOverThreads = false, + includeChatRoomsByParticipants = false, + } = config ?? {}; if (searchInputValue.trim() === '' && maxRecentReportsToShow > 0) { return {...options, recentReports: options.recentReports.slice(0, maxRecentReportsToShow)}; } @@ -2510,6 +2518,10 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt if (item.subtitle) { values.push(item.subtitle); } + + if (includeChatRoomsByParticipants) { + values = values.concat(getParticipantsLoginsArray(item)); + } } if (!item.isChatRoom) { diff --git a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx index fca23d1e1cb9..f0169b410257 100644 --- a/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx +++ b/src/pages/settings/AboutPage/ShareLogList/BaseShareLogList.tsx @@ -27,30 +27,52 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) { const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false}); const {options, areOptionsInitialized} = useOptionsList(); - const searchOptions = useMemo(() => { + const defaultOptions = useMemo(() => { if (!areOptionsInitialized) { return { recentReports: [], personalDetails: [], - userToInvite: undefined, + userToInvite: null, + currentUserOption: null, + categoryOptions: [], + tagOptions: [], + taxRatesOptions: [], headerMessage: '', }; } - const { - recentReports: localRecentReports, - personalDetails: localPersonalDetails, - userToInvite: localUserToInvite, - } = OptionsListUtils.getShareLogOptions(options, debouncedSearchValue.trim(), betas ?? []); + const shareLogOptions = OptionsListUtils.getShareLogOptions(options, '', betas ?? []); - const header = OptionsListUtils.getHeaderMessage((localRecentReports?.length || 0) + (localPersonalDetails?.length || 0) !== 0, !!localUserToInvite, debouncedSearchValue); + const header = OptionsListUtils.getHeaderMessage( + (shareLogOptions.recentReports.length || 0) + (shareLogOptions.personalDetails.length || 0) !== 0, + !!shareLogOptions.userToInvite, + '', + ); return { - recentReports: localRecentReports, - personalDetails: localPersonalDetails, - userToInvite: localUserToInvite, + ...shareLogOptions, headerMessage: header, }; - }, [areOptionsInitialized, options, debouncedSearchValue, betas]); + }, [areOptionsInitialized, options, betas]); + + const searchOptions = useMemo(() => { + if (debouncedSearchValue.trim() === '') { + return defaultOptions; + } + + const filteredOptions = OptionsListUtils.filterOptions(defaultOptions, debouncedSearchValue, { + includeChatRoomsByParticipants: true, + preferChatroomsOverThreads: true, + sortByReportTypeInSearch: true, + }); + + const headerMessage = OptionsListUtils.getHeaderMessage( + (filteredOptions.recentReports?.length || 0) + (filteredOptions.personalDetails?.length || 0) !== 0, + !!filteredOptions.userToInvite, + debouncedSearchValue.trim(), + ); + + return {...filteredOptions, headerMessage}; + }, [debouncedSearchValue, defaultOptions]); const sections = useMemo(() => { const sectionsList = [];