Skip to content

Migrate SearchRouter.tsx from useOptionsList to useFilteredOptions #82186

@mountiny

Description

@mountiny

Problem

SearchRouter.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: areOptionsInitialized only
  • Called with: no arguments
  • File: src/components/Search/SearchRouter/SearchRouter.tsx

How areOptionsInitialized is used:

  • Combined with isRecentSearchesDataLoaded into shouldShowList flag
  • Controls conditional rendering: shows SearchAutocompleteList when true, shows OptionsListSkeletonView when false

Migration steps:

  1. Replace import {useOptionsList} from '@components/OptionListContextProvider' with import useFilteredOptions from '@hooks/useFilteredOptions'
  2. Replace useOptionsList() call with useFilteredOptions({ enabled: true })
  3. Replace areOptionsInitialized with !isLoading in the shouldShowList computation
  4. The rest of the conditional rendering logic should work as-is

Note: This component only uses areOptionsInitialized for gating visibility. The actual options data is consumed by SearchAutocompleteList (a separate migration issue). These two migrations are independent.

Complexity: Simple

Reference PR: #74071

Tests

  • Verify the search router opens and shows the autocomplete list correctly
  • Verify the skeleton loading view shows while options are being computed
  • Verify search functionality works end-to-end
  • Verify no errors appear in the JS console
  • Test on all platforms (iOS, Android, Web, Desktop)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions