Problem
SearchAutocompleteList.tsx currently uses the useOptionsList hook from OptionListContextProvider, which causes unnecessary background recalculations on every personal details or reports change.
This is part of a larger effort to remove OptionListContextProvider entirely. See parent issue #82193 for full context.
Solution
Replace useOptionsList with useFilteredOptions following the pattern established in PR #74071 (NewChatPage migration).
Current usage:
- Properties used:
options, areOptionsInitialized
- Called with: no arguments (defaults to
shouldInitialize: true)
- File:
src/components/Search/SearchAutocompleteList.tsx
How options are used:
options is passed into getSearchOptions() to build searchOptions in a useMemo
options is passed into getSearchOptions() again for autocomplete participants and IN filter in autocompleteSuggestions useMemo
areOptionsInitialized controls early return in searchOptions useMemo (falls back to defaultListOptions when false)
areOptionsInitialized conditionally renders the main SelectionList
Migration steps:
- Replace
import {useOptionsList} from '@components/OptionListContextProvider' with import useFilteredOptions from '@hooks/useFilteredOptions'
- Replace
useOptionsList() call with useFilteredOptions({ enabled: true })
- Replace
areOptionsInitialized with !isLoading (or options !== null)
- Update the
searchOptions useMemo guard to check options !== null instead of areOptionsInitialized
- Update the
autocompleteSuggestions useMemo similarly
- Update the conditional render for
SelectionList
Complexity: Medium -- multiple usages of options across different code paths
Reference PR: #74071
Tests
- Verify search autocomplete works correctly when typing in the search bar
- Verify autocomplete suggestions appear for participants, chats, and IN filters
- Verify fallback to
defaultListOptions works when options are loading
- Verify no errors appear in the JS console
- Test on all platforms (iOS, Android, Web, Desktop)
Issue Owner
Current Issue Owner: @hoangzinh
Problem
SearchAutocompleteList.tsxcurrently uses theuseOptionsListhook fromOptionListContextProvider, which causes unnecessary background recalculations on every personal details or reports change.This is part of a larger effort to remove
OptionListContextProviderentirely. See parent issue #82193 for full context.Solution
Replace
useOptionsListwithuseFilteredOptionsfollowing the pattern established in PR #74071 (NewChatPage migration).Current usage:
options,areOptionsInitializedshouldInitialize: true)src/components/Search/SearchAutocompleteList.tsxHow options are used:
optionsis passed intogetSearchOptions()to buildsearchOptionsin a useMemooptionsis passed intogetSearchOptions()again for autocomplete participants and IN filter inautocompleteSuggestionsuseMemoareOptionsInitializedcontrols early return insearchOptionsuseMemo (falls back todefaultListOptionswhen false)areOptionsInitializedconditionally renders the mainSelectionListMigration steps:
import {useOptionsList} from '@components/OptionListContextProvider'withimport useFilteredOptions from '@hooks/useFilteredOptions'useOptionsList()call withuseFilteredOptions({ enabled: true })areOptionsInitializedwith!isLoading(oroptions !== null)searchOptionsuseMemo guard to checkoptions !== nullinstead ofareOptionsInitializedautocompleteSuggestionsuseMemo similarlySelectionListComplexity: Medium -- multiple usages of
optionsacross different code pathsReference PR: #74071
Tests
defaultListOptionsworks when options are loadingIssue Owner
Current Issue Owner: @hoangzinh