Skip to content

Migrate useSearchSelector.base.ts from useOptionsList to useFilteredOptions #82191

Closed

Description

@mountiny

Problem

useSearchSelector.base.ts 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 (as defaultOptions), areOptionsInitialized
  • Called with: { shouldInitialize } (from hook config, defaults to true)
  • File: src/hooks/useSearchSelector.base.ts

How options are used:

  • options (renamed to defaultOptions) is merged with contactOptions into optionsWithContacts
  • Used as base for baseOptions in switch on searchContext (via getSearchOptions or getValidOptions)
  • areOptionsInitialized guards optionsWithContacts and baseOptions computation
  • areOptionsInitialized is exposed in the return value for consumers

High-impact migration: This is a shared base hook used indirectly by approximately 10 screens:

  • VacationDelegatePage
  • MoneyRequestParticipantsSelector
  • MoneyRequestAttendeeSelector
  • BaseOnboardingWorkspaceInvite
  • WorkspaceInvitePage
  • InviteReportParticipantsPage
  • AssigneeStep (Expensify Card)
  • AssigneeStep (Company Cards)
  • TaskAssigneeSelectorModal
  • BaseShareLogList

Migrating this hook automatically benefits all these indirect consumers.

Migration steps:

  1. Replace import {useOptionsList} from '@components/OptionListContextProvider' with import useFilteredOptions from '@hooks/useFilteredOptions'
  2. Replace useOptionsList({ shouldInitialize }) with useFilteredOptions({ enabled: shouldInitialize }) (or a similar mapping)
  3. Replace areOptionsInitialized with !isLoading (or options !== null)
  4. Update optionsWithContacts and baseOptions guards accordingly
  5. Update the return value to expose the new loading semantics
  6. Verify all ~10 indirect consumers still work correctly

Complexity: Medium (high-impact due to ~10 indirect consumers)

Reference PR: #74071

Tests

  • Verify search selector works across all screens that use useSearchSelector:
    • MoneyRequestParticipantsSelector (create expense > select participant)
    • WorkspaceInvitePage (workspace settings > invite members)
    • InviteReportParticipantsPage (report > invite participants)
    • TaskAssigneeSelectorModal (assign a task)
    • VacationDelegatePage (vacation delegate selection)
    • And other indirect consumers listed above
  • Verify loading placeholders show correctly while options compute
  • Verify search/filter functionality works in each context
  • Verify no errors appear in the JS console
  • Test on all platforms (iOS, Android, Web, Desktop)
Issue OwnerCurrent Issue Owner: @hoangzinh

Activity

  1. melvin-bot commented on Feb 19, 2026

    @melvin-bot

    @hoangzinh, @mountiny, @shubham1206agra Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  2. mountiny commented on Feb 20, 2026

    @mountiny
    ContributorAuthor

    in the backlog

  3. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    @hoangzinh, @mountiny, @shubham1206agra 12 days overdue now... This issue's end is nigh!

  4. mountiny commented on Mar 5, 2026

    @mountiny
    ContributorAuthor

    @shubham1206agra @hungvu193 How is this one looking?

  5. 134 remaining items

  6. hoangzinh commented on Jul 7, 2026

    @hoangzinh
    Contributor

    @shubham1206agra I think we can close this issue. Do you agree?

  7. shubham1206agra commented on Jul 7, 2026

    @shubham1206agra
    Contributor

    @hoangzinh Not right now. We are still addressing the issue that got the last PR reverted

  8. hoangzinh commented on Jul 16, 2026

    @hoangzinh
    Contributor

    Cool. I think we can close this issue. cc @shubham1206agra @mountiny

  9. shubham1206agra commented on Jul 16, 2026

    @shubham1206agra
    Contributor

    @mountiny One PR still remains. Please reopen this.

  10. lanitochka17 commented on Jul 27, 2026

    @lanitochka17

    Deploy Blocker #97163 was identified to be related to the PR #96440 that attempted to fix this issue.

  11. shubham1206agra commented on Jul 30, 2026

    @shubham1206agra
    Contributor

    @mountiny You can close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ReviewingHas a PR in reviewSkip PaymentSkips all the payment process steps for an issue. Use it for fixed-price projects.TaskWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions