@@ -24,23 +24,15 @@ import useIsFocusedRef from '@hooks/useIsFocusedRef';
2424import useLocalize from '@hooks/useLocalize' ;
2525import useNetwork from '@hooks/useNetwork' ;
2626import useOnyx from '@hooks/useOnyx' ;
27- import usePrivateIsArchivedMap from '@hooks/usePrivateIsArchivedMap' ;
2827import useSafeAreaInsets from '@hooks/useSafeAreaInsets' ;
2928import useSingleExecution from '@hooks/useSingleExecution' ;
3029import useThemeStyles from '@hooks/useThemeStyles' ;
3130import { navigateToAndOpenReport , searchInServer , setGroupDraft } from '@libs/actions/Report' ;
3231import { canUseTouchScreen } from '@libs/DeviceCapabilities' ;
3332import Log from '@libs/Log' ;
3433import Navigation from '@libs/Navigation/Navigation' ;
35- import {
36- filterAndOrderOptions ,
37- filterSelectedOptions ,
38- formatSectionsFromSearchTerm ,
39- getHeaderMessage ,
40- getPersonalDetailSearchTerms ,
41- getUserToInviteOption ,
42- getValidOptions ,
43- } from '@libs/OptionsListUtils' ;
34+ import { filterAndOrderOptions , filterSelectedOptions , getHeaderMessage , getUserToInviteOption , getValidOptions } from '@libs/OptionsListUtils' ;
35+ import { doesPersonalDetailMatchSearchTerm } from '@libs/OptionsListUtils/searchMatchUtils' ;
4436import type { OptionWithKey } from '@libs/OptionsListUtils/types' ;
4537import type { OptionData } from '@libs/ReportUtils' ;
4638import variables from '@styles/variables' ;
@@ -141,7 +133,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor
141133 ! ! options . userToInvite ,
142134 debouncedSearchTerm . trim ( ) ,
143135 countryCode ,
144- selectedOptions . some ( ( participant ) => getPersonalDetailSearchTerms ( participant , currentUserAccountID ) . join ( ' ' ) . toLowerCase ?. ( ) . includes ( cleanSearchTerm ) ) ,
136+ selectedOptions . some ( ( participant ) => doesPersonalDetailMatchSearchTerm ( participant , currentUserAccountID , cleanSearchTerm ) ) ,
145137 ) ;
146138
147139 useFocusEffect ( ( ) => {
@@ -247,19 +239,16 @@ function NewChatPage({ref}: NewChatPageProps) {
247239 const personalData = useCurrentUserPersonalDetails ( ) ;
248240 const currentUserAccountID = personalData . accountID ;
249241 const { top} = useSafeAreaInsets ( ) ;
250- const [ allPolicies ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY ) ;
251242 const [ isSearchingForReports ] = useOnyx ( ONYXKEYS . RAM_ONLY_IS_SEARCHING_FOR_REPORTS ) ;
252243 const [ introSelected ] = useOnyx ( ONYXKEYS . NVP_INTRO_SELECTED ) ;
253244 const [ betas ] = useOnyx ( ONYXKEYS . BETAS ) ;
254245 const [ isSelfTourViewed ] = useOnyx ( ONYXKEYS . NVP_ONBOARDING , { selector : hasSeenTourSelector } ) ;
255- const privateIsArchivedMap = usePrivateIsArchivedMap ( ) ;
256246 const selectionListRef = useRef < SelectionListWithSectionsHandle | null > ( null ) ;
257247
258248 const [ reportAttributesDerivedFull ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES ) ;
259249
260250 const reportAttributesDerived = reportAttributesDerivedFull ?. reports ;
261251
262- const allPersonalDetails = usePersonalDetails ( ) ;
263252 const { singleExecution} = useSingleExecution ( ) ;
264253
265254 useImperativeHandle ( ref , ( ) => ( {
@@ -282,20 +271,12 @@ function NewChatPage({ref}: NewChatPageProps) {
282271
283272 const sections : Array < Section < OptionWithKey > > = [ ] ;
284273
285- const formatResults = formatSectionsFromSearchTerm (
286- debouncedSearchTerm ,
287- selectedOptions as OptionData [ ] ,
288- recentReports ,
289- personalDetails ,
290- privateIsArchivedMap ,
291- currentUserAccountID ,
292- allPolicies ,
293- allPersonalDetails ,
294- undefined ,
295- undefined ,
296- reportAttributesDerived ,
297- ) ;
298- sections . push ( { ...formatResults . section , title : undefined , sectionIndex : 0 } ) ;
274+ const selectedSection =
275+ debouncedSearchTerm === ''
276+ ? selectedOptions
277+ : selectedOptions . filter ( ( participant ) => doesPersonalDetailMatchSearchTerm ( participant , currentUserAccountID , debouncedSearchTerm . trim ( ) . toLowerCase ( ) ) ) ;
278+
279+ sections . push ( { data : selectedSection , title : undefined , sectionIndex : 0 } ) ;
299280
300281 sections . push ( {
301282 title : translate ( 'common.recents' ) ,
0 commit comments