-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Labels
Description
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:
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 mainSelectionList
Migration steps:
- Replace
import {useOptionsList} from '@components/OptionListContextProvider'withimport useFilteredOptions from '@hooks/useFilteredOptions' - Replace
useOptionsList()call withuseFilteredOptions({ enabled: true }) - Replace
areOptionsInitializedwith!isLoading(oroptions !== null) - Update the
searchOptionsuseMemo guard to checkoptions !== nullinstead ofareOptionsInitialized - Update the
autocompleteSuggestionsuseMemo 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
defaultListOptionsworks when options are loading - Verify no errors appear in the JS console
- Test on all platforms (iOS, Android, Web, Desktop)
Reactions are currently unavailable