Skip to content

[$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots #96225

Open

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.34-12
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @JmillsExpensify
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Sign in to an account with more than 12 copilots.
  2. Open the Copilot quick switcher.
  3. Observe the available controls.

Expected Result:

The quick switcher should display a search input when there are more than 12 copilots.

Actual Result:

No search input is displayed.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Recording.3224.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @eh2077

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 15, 2026
  2. MelvinBot commented on Jul 15, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The Copilot quick switcher is rendered by AccountSwitcher.tsx, which displays the copilot/delegator list through a plain PopoverMenu (menuItems={menuItems()}).

    PopoverMenu has no search/text-input capability at all — there is no shouldShowTextInput, search value, or filtering prop on the component. So the switcher can never show a search field, no matter how many copilots are in the list.

    Everywhere else in the app, a selection list conditionally shows a search input once it reaches CONST.STANDARD_LIST_ITEM_LIMIT (= 12) — e.g. ApproverSelectionList.tsx:85 uses allApprovers?.length >= CONST.STANDARD_LIST_ITEM_LIMIT. The switcher was never wired up to that convention, so it's the outlier that has no way to search a long copilot list.

    What changes do you think we should make in order to solve the problem?

    Give the switcher a searchable list when the copilot count crosses the standard threshold. The switcher already computes the list from delegators and builds delegatorMenuItems.

    Two viable approaches (implementer to pick after weighing reuse vs. blast radius):

    1. Render the list with SelectionList inside the popover instead of passing menuItems to PopoverMenu, and set shouldShowTextInput={delegators.length >= CONST.STANDARD_LIST_ITEM_LIMIT}. This reuses the exact pattern (and 12-item threshold) already used across approver/tax/vacation-delegate pickers, giving free, consistent search + filtering behavior.
    2. Add optional search support to PopoverMenu (a shouldShowTextInput/filter prop that renders a text input in the header and filters menuItems by text/description). Higher blast radius since PopoverMenu is widely shared, but keeps the switcher's current structure.

    Approach 1 is preferred — it matches the established convention with the least new surface area.

    What alternative solutions did you explore? (Optional)

    Hard-coding a search box always-on in the switcher was considered, but that diverges from the app-wide behavior of only showing search past the 12-item limit, so gating on CONST.STANDARD_LIST_ITEM_LIMIT is the right call.

    Investigation notes / confidence
    • Confirmed PopoverMenu/index.tsx exposes no search/text-input prop (grep for search/textInput returns nothing in the component).
    • STANDARD_LIST_ITEM_LIMIT is 12, matching the "more than 12 copilots" symptom exactly.
    • The fix is entirely within the App repo (src/components/AccountSwitcher.tsx, optionally PopoverMenu), so no backend/other-repo work is needed.
    • Confidence: Medium-High — root cause verified in code; the two fix paths are design choices for the implementer, not open questions about the cause.

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/96225) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 15, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 15, 2026
  5. MobileMage commented on Jul 15, 2026

    @MobileMage
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-15 22:02:12 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When an account has more than 12 copilots, opening the Copilot quick switcher (the account switcher popover in the sidebar) shows only a long scrollable list of accounts with no search input. Every other long list in the app (categories, tags, workspaces, members) shows a "Search" text input once it reaches 12 items, so users with many copilots have no way to quickly find the account they want to switch to.

    The issue owner has since clarified the scope (#96225 (comment)): once the threshold is met, the search input is needed in two places, the quick switcher popover and the Copilots page, covering both the accounts you can access and the members who can access your account.

    What is the root cause of that problem?

    The quick switcher is AccountSwitcher, and it renders its copilot list through a plain PopoverMenu:

    {!!canSwitchAccounts && (
    <PopoverMenu
    isVisible={shouldShowDelegatorMenu}
    onClose={hideDelegatorMenu}
    onItemSelected={hideDelegatorMenu}

    AccountSwitcher builds the rows in menuItems() (src/components/AccountSwitcher.tsx lines 163 to 224): the current user row plus one PopoverMenuItem per entry in account.delegatedAccess.delegators, sorted with sortAlphabetically. Nothing in this component measures the list size, so the full unfiltered array is always passed down regardless of how many copilots exist.

    PopoverMenu itself has no concept of a search input. BasePopoverMenu renders exactly three things inside its content container, and none of them is a text input (src/components/PopoverMenu/index.tsx):

    >
    {renderHeaderText()}
    {enteredSubMenuIndexes.length > 0 && renderBackButtonItem()}
    {renderedMenuItems}
    </PopoverMenuContent>

    The app-wide convention is CONST.STANDARD_LIST_ITEM_LIMIT: 12 (src/CONST/index.ts line 5196): pickers show a search input once the list reaches 12 items, for example CategoryPicker/index.tsx line 93 with shouldShowTextInput={categoriesCount >= CONST.STANDARD_LIST_ITEM_LIMIT} and DynamicNewReportWorkspaceSelectionPage.tsx line 257. That convention is implemented by SelectionList consumers and by pages that mount SearchBar above a list, but the copilot switcher never went through either path, so the threshold check simply does not exist anywhere on this code path. There is no broken condition to flip; the capability is missing from both AccountSwitcher and the PopoverMenu it uses.

    I reproduced this with an account that has 13 copilots: opening the account switcher from Settings shows the 'Switch accounts:' popover with the current account's radio selected and all 13 copilot rows with their Full/Limited role badges, but no search input appears anywhere; with the popover open the document contains zero input or textarea elements and nothing carrying a search label or placeholder. The underlying account data is correct, all 13 delegators are present and render, and the console stays clean through the whole flow, so nothing throws and nothing filters; the failure is that the capability does not exist on this path. The list flows unfiltered from menuItems() in src/components/AccountSwitcher.tsx straight into PopoverMenu, whose content renders only the header text and the menu rows (src/components/PopoverMenu/index.tsx lines 723-727), and neither file references SearchBar, shouldShowTextInput, useSearchResults, or CONST.STANDARD_LIST_ITEM_LIMIT, so the 12-item search convention has no hook here.

    The Copilots page has the same gap through a simpler path: src/pages/settings/Copilot/CopilotPage.tsx builds delegatorMenuItems and delegateMenuItems (lines 203 to 309) and renders each through a plain MenuItemList:

    {hasDelegators && (
    <>
    <Text style={[styles.textLabelSupporting, styles.pv1]}>{translate('delegate.youCanAccessTheseAccounts')}</Text>
    <MenuItemList menuItems={delegatorMenuItems} />
    </>
    )}
    {hasDelegates && (
    <>
    <Text style={[styles.textLabelSupporting, styles.pv1, hasDelegators && styles.mt5]}>{translate('delegate.membersCanAccessYourAccount')}</Text>
    <MenuItemList menuItems={delegateMenuItems} />
    </>
    )}

    Nothing on that page measures list size or mounts a SearchBar either, so both lists grow unbounded with no way to filter them.

    What changes do you think we should make in order to solve the problem?

    We should reuse the existing building blocks instead of writing new search logic: the SearchBar component (src/components/SearchBar.tsx), the useSearchResults hook (src/hooks/useSearchResults.ts, which already handles debouncing and resets the input when the dataset drops back under STANDARD_LIST_ITEM_LIMIT), and tokenizedSearch (src/libs/tokenizedSearch.ts).

    In AccountSwitcher, extract the delegator rows out of menuItems() into a memoized delegatorMenuItems array (the existing lines 197 to 221 unchanged), then pipe them through the hook and gate the search on the standard threshold, matching the issue's expected behavior:

    const shouldShowSearchInput = !isActingAsDelegate && delegatorMenuItems.length >= CONST.STANDARD_LIST_ITEM_LIMIT;
    const filterDelegators = (item: PopoverMenuItem, search: string) => tokenizedSearch([item], search, (option) => [option.text, option.description ?? '']).length > 0;
    const [searchInput, setSearchInput, filteredDelegatorMenuItems] = useSearchResults(delegatorMenuItems, filterDelegators);

    The menu becomes [currentUserMenuItem, ...filteredDelegatorMenuItems], so the pinned current-user row is never filtered out and searching matches both display name and login. In PopoverMenu, add four optional props (searchInputLabel, searchInputValue, onSearchInputChange, shouldShowSearchEmptyState) and, when searchInputLabel is set, render the header plus a SearchBar above PopoverMenuContent so the input stays pinned while the list scrolls; when the props are absent, rendering is byte-for-byte identical to today, so ButtonWithDropdownMenu and every other consumer is unaffected. AccountSwitcher then passes searchInputLabel={shouldShowSearchInput ? translate('common.search') : undefined}, searchInputValue={searchInput}, onSearchInputChange={setSearchInput}, and shouldShowSearchEmptyState={shouldShowSearchInput && filteredDelegatorMenuItems.length === 0} to surface the existing "No results found" copy. One subtle but required piece: PopoverMenu is exported through React.memo with a custom comparator that only compares a fixed list of props:

    export default React.memo(
    PopoverMenu,
    (prevProps, nextProps) =>
    // eslint-disable-next-line rulesdir/no-deep-equal-in-memo -- menuItems array is created inline in most usages with unstable references
    deepEqual(prevProps.menuItems, nextProps.menuItems) &&

    If the user types a character that does not change the filtered results, deepEqual(menuItems) passes and the popover would skip the re-render, leaving the controlled TextInput stale, so searchInputValue, searchInputLabel, and shouldShowSearchEmptyState must be added to that comparator. Filtering itself needs no changes inside PopoverMenu: the existing useLayoutEffect at line 591 already syncs currentMenuItems whenever menuItems changes (the sub-menu key path is empty here), and useArrowKeyFocusManager derives maxIndex from currentMenuItems.length - 1, so arrow-key navigation and Enter keep working over the filtered rows. When acting as a delegate the menu has at most two rows and shouldShowSearchInput stays false, so that branch is untouched.

    For the Copilots page the same threshold and building blocks apply, and no PopoverMenu change is involved: the page already builds its rows from sortedDelegators and sortedDelegates, where every entry carries the resolved display name (sortKey) and email. When delegators.length + delegates.length >= CONST.STANDARD_LIST_ITEM_LIMIT, render the same SearchBar below the section subtitle and filter the two source arrays with tokenizedSearch on [sortKey, email] before they are mapped to menu items; running useSearchResults over the combined array and partitioning it back into the two lists keeps its debounce and its under-limit reset. Each sub-header ('You can access these accounts' / 'Members can access your account') is hidden while its filtered list is empty, the standard no-results copy shows when both are, and the 'Add copilot' row stays outside the filter.

    What specific alternative solutions were considered (if any) and why is the primary solution better? (optional)

    Replacing the popover body with a SelectionList (which already implements shouldShowTextInput) was considered, but no compact anchored popover in the app hosts a SelectionList, and the switcher relies on PopoverMenu/MenuItem behavior it would lose or have to reimplement: radio-button mode, per-row badgeText for the copilot role, per-row errorText with red dot indicators via OfflineWithFeedback, and the measured-content anchoring. Extending PopoverMenu with an optional pinned SearchBar is a much smaller, opt-in change that reuses the exact search pattern already shipped in SpendRuleSelectionPage and WorkspaceWorkflowsPage.

    What automated tests can be added to prevent regression? (optional)

    A React Native Testing Library test alongside the existing delegate tests (tests/unit/DelegateAccessHandlerTest.tsx) that renders AccountSwitcher with account.delegatedAccess.delegators seeded with 12+ entries in Onyx, opens the switcher, and asserts the search input is present; typing a query should narrow the visible rows to matching copilots plus the current-user row, and a second case with fewer than 12 delegators should assert the input is absent. For the Copilots page, a similar test seeding 12 or more combined delegates and delegators should assert the search input renders, that a query narrows both lists by name and email, and that the input is absent below the threshold.

  6. aswin-s commented on Jul 15, 2026

    @aswin-s
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Web/Desktop, when a user with more than 12 copilots opens the Copilot quick switcher (the AccountSwitcher popover in the sidebar), no search input is rendered, forcing the user to scroll through the entire delegator list. The expected behavior is that the popover exposes a search input once the delegator list crosses a size threshold (>12) so the user can filter copilots quickly.

    What is the root cause of that problem?

    AccountSwitcher (src/components/AccountSwitcher.tsx:299-320) renders PopoverMenu with the full menuItems() list and never provides a search/filter affordance. menuItems() (src/components/AccountSwitcher.tsx:163-224) builds one PopoverMenuItem per delegator via sortAlphabetically(...) on lines 197-221 with no truncation or filtering — every copilot is passed straight into the popover. The PopoverMenu component itself (src/components/PopoverMenu/index.tsx) has no searchValue/shouldShowSearchInput prop, so nothing downstream can inject a search box either. The result: regardless of delegator count, the switcher shows an unfiltered scroll list only.

    What changes do you think we should make in order to solve the problem?

    1. In src/components/AccountSwitcher.tsx add local searchValue state (reset on hideDelegatorMenu) and, when delegators.length > CONST.COPILOT_SEARCH_INPUT_THRESHOLD (new constant = 12), filter the delegatorMenuItems in menuItems() (lines 197-221) by matching searchValue against each delegator's displayName/login (using formatPhoneNumber + Str.removeSMSDomain) before passing to PopoverMenu.
    2. Render a TextInput (search field) inside the popover for the >12-copilots case. Options: (a) extend PopoverMenu (src/components/PopoverMenu/index.tsx) with a new shouldShowSearchInput/searchValue/onChangeSearchValue/searchInputPlaceholder prop set that renders a sticky header TextInput above the menu list; or (b) wrap the popover contents in a custom header via existing header slots. Prefer (a) so other call sites can reuse it.
    3. Add the new translation key delegate.searchCopilots (or reuse common.search) for the input placeholder in src/languages/*.
    4. Ensure the delegator's email is included in the searchable text so users can find copilots by login when the display name is empty.
    5. Keep shouldUseScrollView and the existing maxHeight: windowHeight / 2 so the input remains sticky while results scroll (line 312).

    What alternative solutions did you explore? (Optional)

  7. ahmdshrif commented on Jul 15, 2026

    @ahmdshrif
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user has more than 12 copilots, the Copilot quick switcher (the account switcher popover) shows the full list with no search input, so there is no way to filter and find a specific copilot.

    What is the root cause of that problem?

    The copilot quick switcher is rendered by AccountSwitcher, which builds the copilot/delegator rows in menuItems() and hands them to a plain PopoverMenu:

    • <PopoverMenu
      isVisible={shouldShowDelegatorMenu}
      onClose={hideDelegatorMenu}
      onItemSelected={hideDelegatorMenu}
      anchorRef={buttonRef}
      anchorPosition={CONST.POPOVER_ACCOUNT_SWITCHER_POSITION}
      anchorAlignment={{
      horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
      vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
      }}
      menuItems={menuItems()}
      headerText={translate('delegate.switchAccount')}
    • const menuItems = (): PopoverMenuItem[] => {
      const currentUserMenuItem = createBaseMenuItem(currentUserPersonalDetails, undefined, {isSelected: true});
      if (isActingAsDelegate) {
      const delegateEmail = account?.delegatedAccess?.delegate ?? '';
      // Avoid duplicating the current user in the list when switching accounts
      if (delegateEmail === currentUserPersonalDetails.login) {
      return [currentUserMenuItem];
      }
      const delegatePersonalDetails = getPersonalDetailByEmail(delegateEmail);
      const error = getLatestError(account?.delegatedAccess?.errorFields?.disconnect);
      return [
      createBaseMenuItem(delegatePersonalDetails, error, {
      onSelected: () => {
      if (isOffline) {
      close(showOfflineModal);
      return;
      }
      if (isTrackingGPS) {
      close(() => showGpsInProgressModal(() => disconnect({stashedCredentials, stashedSession})));
      return;
      }
      disconnect({stashedCredentials, stashedSession});
      },
      }),
      currentUserMenuItem,
      ];
      }
      const delegatorMenuItems: PopoverMenuItem[] = sortAlphabetically(
      delegators
      .filter(({email}) => email !== currentUserPersonalDetails.login)
      .map(({email, role}) => {
      const errorFields = account?.delegatedAccess?.errorFields ?? {};
      const error = getLatestError(errorFields?.connect?.[email]);
      const personalDetails = getPersonalDetailByEmail(email);
      return createBaseMenuItem(personalDetails, error, {
      badgeText: translate('delegate.role', {role}),
      onSelected: () => {
      if (isOffline) {
      close(showOfflineModal);
      return;
      }
      if (isTrackingGPS) {
      close(() => showGpsInProgressModal(() => connect({email, delegatedAccess: account?.delegatedAccess, credentials, session, activePolicyID})));
      return;
      }
      connect({email, delegatedAccess: account?.delegatedAccess, credentials, session, activePolicyID});
      },
      });
      }),
      'text',
      localeCompare,
      );
      return [currentUserMenuItem, ...delegatorMenuItems];
      };

    PopoverMenu has no search/filter TextInput at all (zero references to search/text-input/filter in src/components/PopoverMenu/index.tsx). Every other long list in the app instead gates a search box on the shared threshold CONST.STANDARD_LIST_ITEM_LIMIT (= 12), e.g. shouldShowTextInput={count >= CONST.STANDARD_LIST_ITEM_LIMIT} in the category/tag/approver pickers:

    Because the switcher never opts into that pattern, once the list crosses the 12-item threshold it stays unfilterable.

    What changes do you think we should make in order to solve the problem?

    Show a filter TextInput in the copilot switcher when the copilot count reaches the standard threshold, matching the rest of the app. Gate it on the same constant and filter menuItems() by the typed value:

    const shouldShowSearchInput = delegators.length >= CONST.STANDARD_LIST_ITEM_LIMIT;
    // render a TextInput above the list when shouldShowSearchInput,
    // and filter delegatorMenuItems by display name / login on the search value
    

    This can live in AccountSwitcher (filtering menuItems() before passing to PopoverMenu) or by adding a search-input capability to PopoverMenu; the AccountSwitcher-local filter is the smaller, lower-risk change. Regression risk is limited to the switcher popover — lists of ≤11 copilots are unaffected since the input only appears at/above the existing 12-item threshold.

  8. lorretheboy commented on Jul 15, 2026

    @lorretheboy
    Contributor

    Proposal

    What is the root cause of that problem?

    The copilot quick switcher renders its account list through the legacy PopoverMenu (v1), whose public API is a closed array-of-config: AccountSwitcher builds plain data objects in menuItems() and hands them over as menuItems={menuItems()}.

    {!!canSwitchAccounts && (
    <PopoverMenu
    isVisible={shouldShowDelegatorMenu}
    onClose={hideDelegatorMenu}
    onItemSelected={hideDelegatorMenu}
    anchorRef={buttonRef}
    anchorPosition={CONST.POPOVER_ACCOUNT_SWITCHER_POSITION}
    anchorAlignment={{
    horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
    vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
    }}
    menuItems={menuItems()}
    headerText={translate('delegate.switchAccount')}
    containerStyles={[{maxHeight: windowHeight / 2}, styles.mw100, shouldUseNarrowLayout ? {} : styles.wFitContent]}
    headerStyles={styles.pt0}
    innerContainerStyle={styles.pb0}
    shouldUseScrollView
    shouldUpdateFocusedIndex={false}
    enableEdgeToEdgeBottomSafeAreaPadding
    shouldShowRadioButton
    />

    The reason no search input can appear is not simply "the feature was never written" — it's that v1's contract has no seam to put one in. The caller cannot hand v1 arbitrary content; it can only hand it row descriptors, and v1 renders exactly a header plus those rows:

    <PopoverMenuContent
    shouldUseScrollView={shouldUseScrollView}
    contentContainerStyle={[scrollViewPaddingStyles, restScrollContainerStyle]}
    addBottomSafeAreaPadding={enableEdgeToEdgeBottomSafeAreaPadding}
    >
    {renderHeaderText()}
    {enteredSubMenuIndexes.length > 0 && renderBackButtonItem()}
    {renderedMenuItems}
    </PopoverMenuContent>

    That closed shape is precisely the problem the repo has already solved: PopoverMenu/v2 is a compound, Radix-style primitive set where the caller composes the popover's contents, and it explicitly supports caller-supplied non-row content inside <Content> via useIsAtActiveLevel():

    ### Custom non-row content — `useIsAtActiveLevel()`
    Hook for self-gating custom (non-row) content rendered directly inside `<Content>` or `<Sub.Content>`. Returns `true` when the enclosing `<Sub>`'s id is the current sub-level (or when the consumer is at the top level and no sub is active). Custom content should render `null` when this is `false` so siblings at other levels don't show through. Requires `<Content>`; `<Sub>` is optional (top-level use returns `true` when no sub is active).

    v2 is not a sketch — it is exported and already used in production by the video player menu:

    https://github.com/Expensify/App/blob/c81c4b77f18063b8837200f6fb54428d570b4ed6/src/components/PopoverMenu/v2/index.tsx

    https://github.com/Expensify/App/blob/c81c4b77f18063b8837200f6fb54428d570b4ed6/src/components/VideoPopoverMenu/index.tsx

    So the root cause is that the switcher sits on the legacy closed API while the composable replacement that makes a search field expressible already exists. Nothing ever compares the delegator count to CONST.STANDARD_LIST_ITEM_LIMIT (12) because, on v1, there is nowhere for the resulting input to go:

    STANDARD_LIST_ITEM_LIMIT: 12,

    What changes do you think we should make in order to solve the problem?

    Migrate AccountSwitcher to PopoverMenu v2 and compose the search field, instead of bolting search props onto v1.

    Replace the single <PopoverMenu menuItems={menuItems()} /> call site with the v2 compound tree: <Root> / <Trigger> wrapping the existing PressableWithFeedback, <ScrollableContent> for the capped list, <Header> for delegate.switchAccount, and one <RadioItem> per account. <RadioItem> already covers everything createBaseMenuItem produces today — it renders MenuItem and wraps it in OfflineWithFeedback:

    function RadioItem({text, isSelected = false, onSelect, disabled = false, pendingAction, testID, rightIcon, iconWidth, iconHeight, ...rest}: RadioItemProps): React.ReactElement | null {
    const theme = useTheme();
    const styles = useThemeStyles();
    const StyleUtils = useStyleUtils();
    useContentClose(RadioItem.displayName);
    const {ref, focused, onPress, onFocus, isAtActiveLevel} = useSelectableRow({onSelect, disabled, text});
    if (!isAtActiveLevel) {
    return null;
    }
    return (
    <OfflineWithFeedback pendingAction={pendingAction}>
    <MenuItem
    {...rest}
    ref={ref}
    title={text}
    iconWidth={iconWidth ?? variables.iconSizeNormal}
    iconHeight={iconHeight ?? variables.iconSizeNormal}
    iconRight={rightIcon}
    shouldShowRightIcon={!!rightIcon}
    shouldShowRadioButton={!rightIcon}
    disabled={disabled}
    interactive
    isSelected={isSelected}
    // Skip the row tint when the radio indicator is the visual cue.
    wrapperStyle={StyleUtils.getItemBackgroundColorStyle(!!rightIcon && isSelected, focused, disabled, theme.activeComponentBG, theme.hoverComponentBG)}
    titleStyle={styles.flex1}
    shouldRemoveHoverBackground={isSelected}
    onPress={onPress}
    onFocus={onFocus}
    focused={focused}
    shouldCheckActionAllowedOnPress={false}
    role={CONST.ROLE.MENUITEM}
    pressableTestID={testID ?? `PopoverMenu.RadioItem-${text}`}
    />
    </OfflineWithFeedback>
    );
    }

    and MenuItemForwardProps passes through the rest of MenuItemProps, so badgeText (the role badge), icon/iconType/avatarID, description, errorText, and shouldShowRedDotIndicator all survive the move unchanged:

    type MenuItemForwardProps = DistributiveOmit<
    MenuItemProps,
    | 'title'
    | 'onPress'
    | 'interactive'
    | 'role'
    | 'shouldCheckActionAllowedOnPress'
    | 'pressableTestID'
    | 'focused'
    | 'onFocus'
    | 'iconRight'
    | 'shouldShowRightIcon'
    | 'isSelected'
    | 'disabled'
    | 'pendingAction'
    | 'ref'
    >;

    The search field then becomes ordinary composed content — a small CopilotSearchInput rendered as the first child of <ScrollableContent>, self-gating on useIsAtActiveLevel() per the v2 contract, holding searchValue locally, and gated on the standard threshold:

    <PopoverMenu.ScrollableContent ...>
        <PopoverMenu.Header>{translate('delegate.switchAccount')}</PopoverMenu.Header>
        {delegators.length >= CONST.STANDARD_LIST_ITEM_LIMIT && (
            <CopilotSearchInput value={searchValue} onChangeText={setSearchValue} label={translate('common.search')} />
        )}
        <PopoverMenu.RadioItem {...currentUserRow} isSelected />
        {filteredDelegators.map((d) => <PopoverMenu.RadioItem key={d.email} {...rowFor(d)} />)}
    </PopoverMenu.ScrollableContent>

    Filtering is just not rendering the non-matching <RadioItem> children (match on display name + login, keeping the current-user row pinned), and the no-results case is a <Label> row.

    Two concrete correctness wins that fall out of this and are not available on v1:

    1. Keyboard navigation stays correct for free. v2's focus registry is keyed by row ID and derives order from the actually-mounted rows, so filtered-out rows unregister and the arrow-key order re-derives itself:

    function useFocusableRegistry({isVisible}: {isVisible: boolean}): UseFocusableRegistryResult {
    const [registry, setRegistry] = useState<Map<string, FocusableItem>>(() => new Map());
    const orderedIDs = useOrderedIDs(registry);
    const disabledIndexes = orderedIDs.flatMap((id, index) => (registry.get(id)?.isDisabled ? [index] : []));
    const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({maxIndex: orderedIDs.length - 1, isActive: isVisible, initialFocusedIndex: -1, disabledIndexes});
    // Guard `-1` (nothing focused); `.at(-1)` would return the last item.
    const focusedID = focusedIndex >= 0 ? (orderedIDs.at(focusedIndex) ?? null) : null;

    On v1, focusedIndex is an index into a static array, so any filtering approach has to manually re-sync focus on every keystroke or the highlight silently points at the wrong copilot.

    1. No new prop on a hand-maintained memo allowlist. v1 is wrapped in a React.memo whose comparator enumerates props explicitly — any new search prop is invisible to it unless the comparator is also edited, which is an easy stale-callback trap for every future caller:

    }
    export default React.memo(
    PopoverMenu,
    (prevProps, nextProps) =>
    // eslint-disable-next-line rulesdir/no-deep-equal-in-memo -- menuItems array is created inline in most usages with unstable references
    deepEqual(prevProps.menuItems, nextProps.menuItems) &&
    prevProps.isVisible === nextProps.isVisible &&
    // eslint-disable-next-line rulesdir/no-deep-equal-in-memo -- anchorPosition object is created inline in most usages
    deepEqual(prevProps.anchorPosition, nextProps.anchorPosition) &&
    prevProps.anchorRef === nextProps.anchorRef &&
    prevProps.headerText === nextProps.headerText &&
    prevProps.fromSidebarMediumScreen === nextProps.fromSidebarMediumScreen &&
    // eslint-disable-next-line rulesdir/no-deep-equal-in-memo -- anchorAlignment object is created inline in most usages
    deepEqual(prevProps.anchorAlignment, nextProps.anchorAlignment) &&
    prevProps.animationIn === nextProps.animationIn &&
    prevProps.animationOut === nextProps.animationOut &&
    prevProps.animationInTiming === nextProps.animationInTiming &&
    prevProps.disableAnimation === nextProps.disableAnimation &&
    prevProps.withoutOverlay === nextProps.withoutOverlay &&
    prevProps.shouldSetModalVisibility === nextProps.shouldSetModalVisibility,

    Scope is one call site plus one small input component; v1 keeps its exact current API, so none of its many other callers are touched at all. Note <ScrollableContent> renders children inside a ScrollView, so keeping the input pinned while results scroll wants stickyHeaderIndices on that ScrollView — a contained addition to ScrollableContent. v2 requires Fabric, which the app already runs.

    What alternative solutions did you explore? (Optional)

    • Add opt-in search props (shouldShowTextInput / searchValue / onChangeSearchValue) to the shared v1 PopoverMenu. This widens the API of a heavily-shared legacy component for one caller, forces the manual focusedIndex re-sync described above, and requires editing the memo comparator in lockstep — all to add a capability v2 already expresses by composition. It also pushes new investment into the component v2 is meant to replace.
    • Keep the filtering entirely local to AccountSwitcher and render a TextInput above the popover. The input then lives outside the popover surface rather than inside it, and it still inherits v1's stale focusedIndex problem.
    • Swap the popover's contents for a SelectionList with shouldShowTextInput. Reuses standard search/empty-state behaviour outright, but rewrites the switcher's radio rows, role badges, offline error dots, and GPS-confirmation flow for a single caller.
  9. samranahm commented on Jul 15, 2026

    @samranahm
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-31 13:38:42 UTC.

    Proposal

    What is the root cause of that problem?

    When someone has 12+ copilots and opens the Switch accounts popover, they only get a long scrollable list. There is no Find member field, so filtering by name/email is not possible. The same gap shows up on the Copilots settings page once the combined to/from list gets long.

    The quick switcher lives in AccountSwitcher and always feeds a plain PopoverMenu with menuItems():

    <PopoverMenu
    isVisible={shouldShowDelegatorMenu}
    onClose={hideDelegatorMenu}
    onItemSelected={hideDelegatorMenu}
    anchorRef={buttonRef}
    anchorPosition={popoverPosition ?? CONST.POPOVER_ACCOUNT_SWITCHER_POSITION}
    anchorAlignment={{
    horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
    vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
    }}
    menuItems={menuItems()}
    headerText={translate('delegate.switchAccount')}
    containerStyles={[{maxHeight: windowHeight / 2}, styles.mw100, shouldUseNarrowLayout ? {} : styles.wFitContent]}
    headerStyles={styles.pt0}
    innerContainerStyle={styles.pb0}
    shouldUseScrollView
    shouldUpdateFocusedIndex={false}
    enableEdgeToEdgeBottomSafeAreaPadding
    shouldShowRadioButton
    />

    That path never checks CONST.STANDARD_LIST_ITEM_LIMIT (12), and never mounts a search field:

    STANDARD_LIST_ITEM_LIMIT: 12,

    PopoverMenu itself can only render the header text, optional back row, and menu rows inside its scroll content. There is no slot for caller-owned content above the rows:

    <PopoverMenuContent
    shouldUseScrollView={shouldUseScrollView}
    contentContainerStyle={[scrollViewPaddingStyles, restScrollContainerStyle]}
    addBottomSafeAreaPadding={enableEdgeToEdgeBottomSafeAreaPadding}
    >
    {renderHeaderText()}
    {enteredSubMenuIndexes.length > 0 && renderBackButtonItem()}
    {renderedMenuItems}
    </PopoverMenuContent>

    So even if AccountSwitcher wanted a SearchBar, the shared menu has nowhere to put it without scrolling the input away with the list.

    The Copilots page has the same kind of gap on a simpler path. It builds delegatorMenuItems / delegateMenuItems and renders both through MenuItemList with no size check and no filter:

    {hasDelegators && (
    <>
    <Text style={[styles.textLabelSupporting, styles.pv1]}>{translate('delegate.youCanAccessTheseAccounts')}</Text>
    <MenuItemList menuItems={delegatorMenuItems} />
    </>
    )}
    {hasDelegates && (
    <>
    <Text style={[styles.textLabelSupporting, styles.pv1, hasDelegators && styles.mt5]}>{translate('delegate.membersCanAccessYourAccount')}</Text>
    <MenuItemList menuItems={delegateMenuItems} />
    </>
    )}

    Jmills also clarified we need search in both places once the threshold is hit: quick switcher at 12+ copilots you can access, and Copilots page when the combined access to/from count is 12+.

    What changes do you think we should make in order to solve the problem?

    Reuse existing search helpers (SearchBar, useSearchResults, tokenizedSearch) and keep the switcher on PopoverMenu, but give the menu a generic place for pinned chrome.

    1. In PopoverMenu, add an optional aboveListContent ReactNode. At the root menu only, render it under the header. When shouldUseScrollView is on, keep the header + that content outside the ScrollView so the search field stays pinned while rows scroll. Also exclude INPUT from Enter capture so typing Enter in the field does not select a row, clamp focused index when filtering shrinks the list, and include aboveListContent in the custom memo comparator:

    type PopoverMenuProps = Partial<ModalAnimationProps> & {
    /** Callback method fired when the user requests to close the modal */
    onClose: () => void;
    /** Optional callback passed to popover's children container */
    onLayout?: (e: LayoutChangeEvent) => void;
    /** Callback method fired when the modal is shown */
    onModalShow?: () => void;
    /** Callback method fired when the modal is hidden */
    onModalHide?: () => void;
    /** State that determines whether to display the modal or not */
    isVisible: boolean;
    /** Callback to fire when a CreateMenu item is selected */
    onItemSelected?: (selectedItem: PopoverMenuItem, index: number, event?: GestureResponderEvent | KeyboardEvent) => void;
    /** Menu items to be rendered on the list */
    menuItems: PopoverMenuItem[];
    /** Optional non-interactive text to display as a header for any create menu */
    headerText?: string;
    /** Whether disable the animations */
    disableAnimation?: boolean;
    /** The horizontal and vertical anchors points for the popover */
    anchorPosition: AnchorPosition;
    /** Ref of the anchor */
    anchorRef: RefObject<View | HTMLDivElement | null>;
    /** Where the popover should be positioned relative to the anchor points. */
    anchorAlignment?: AnchorAlignment;
    /** Whether we don't want to show overlay */
    withoutOverlay?: boolean;
    /** Should we announce the Modal visibility changes? */
    shouldSetModalVisibility?: boolean;
    /** Whether we want to show the popover on the right side of the screen */
    fromSidebarMediumScreen?: boolean;
    shouldHandleNavigationBack?: boolean;
    /**
    * Whether the modal should enable the new focus manager.
    * We are attempting to migrate to a new refocus manager, adding this property for gradual migration.
    * */
    shouldEnableNewFocusManagement?: boolean;
    /** How to re-focus after the modal is dismissed */
    restoreFocusType?: BaseModalProps['restoreFocusType'];
    /** Whether to show a radio button on each item to indicate which one is currently selected */
    shouldShowRadioButton?: boolean;
    /** The style of content container which wraps all child views */
    containerStyles?: StyleProp<ViewStyle>;
    /** Used to apply styles specifically to the header text */
    headerStyles?: StyleProp<TextStyle>;
    /** Modal container styles */
    innerContainerStyle?: ViewStyle;
    /** These styles will be applied to the scroll view content container which wraps all of the child views */
    scrollContainerStyle?: StyleProp<ViewStyle>;
    /** Whether we should wrap the list item in a scroll view */
    shouldUseScrollView?: boolean;
    /**
    * Whether we should set a max height to the popover content.
    * Ignored in landscape mode to prevent content from being unreachable.
    * */
    shouldEnableMaxHeight?: boolean;
    /** Whether to update the focused index on a row select */
    shouldUpdateFocusedIndex?: boolean;
    /** Should we apply padding style in modal itself. If this value is false, we will handle it in ScreenWrapper */
    shouldUseModalPaddingStyle?: boolean;
    /** Whether we want to avoid the safari exception of ignoring shouldCallAfterModalHide */
    shouldAvoidSafariException?: boolean;
    /** Whether to preserve focus on sub items after selection */
    shouldMaintainFocusAfterSubItemSelect?: boolean;
    /** Used to locate the component in the tests */
    testID?: string;
    /** Badge style to be shown near the right end. */
    badgeStyle?: StyleProp<ViewStyle>;
    /**
    * Temporary flag to disable safe area bottom spacing in modals and to allow edge-to-edge content.
    * Modals should not always apply bottom safe area padding, instead it should be applied to the scrollable/bottom-docked content directly.
    * This flag can be removed, once all components/screens have switched to edge-to-edge safe area handling.
    */
    enableEdgeToEdgeBottomSafeAreaPadding?: boolean;
    };

    export default React.memo(
    PopoverMenu,
    (prevProps, nextProps) =>
    // eslint-disable-next-line rulesdir/no-deep-equal-in-memo -- menuItems array is created inline in most usages with unstable references
    deepEqual(prevProps.menuItems, nextProps.menuItems) &&
    prevProps.isVisible === nextProps.isVisible &&
    // eslint-disable-next-line rulesdir/no-deep-equal-in-memo -- anchorPosition object is created inline in most usages
    deepEqual(prevProps.anchorPosition, nextProps.anchorPosition) &&
    prevProps.anchorRef === nextProps.anchorRef &&
    prevProps.headerText === nextProps.headerText &&
    prevProps.fromSidebarMediumScreen === nextProps.fromSidebarMediumScreen &&
    // eslint-disable-next-line rulesdir/no-deep-equal-in-memo -- anchorAlignment object is created inline in most usages
    deepEqual(prevProps.anchorAlignment, nextProps.anchorAlignment) &&
    prevProps.animationIn === nextProps.animationIn &&
    prevProps.animationOut === nextProps.animationOut &&
    prevProps.animationInTiming === nextProps.animationInTiming &&
    prevProps.disableAnimation === nextProps.disableAnimation &&
    prevProps.withoutOverlay === nextProps.withoutOverlay &&
    prevProps.shouldSetModalVisibility === nextProps.shouldSetModalVisibility,
    );

    When the prop is omitted, rendering stays the same as today for every other caller.

    1. In AccountSwitcher, build the delegator rows separately, then put current user + delegators through useSearchResults + tokenizedSearch on display name and login. Show search when delegatorMenuItems.length >= CONST.STANDARD_LIST_ITEM_LIMIT and the user is not acting as a delegate:

    const menuItems = (): PopoverMenuItem[] => {
    const currentUserMenuItem = createBaseMenuItem(currentUserPersonalDetails, undefined, {isSelected: true});
    if (isActingAsDelegate) {
    const delegateEmail = account?.delegatedAccess?.delegate ?? '';
    // Avoid duplicating the current user in the list when switching accounts
    if (delegateEmail === currentUserPersonalDetails.login) {
    return [currentUserMenuItem];
    }
    const delegatePersonalDetails = getPersonalDetailByEmail(delegateEmail);
    const error = getLatestError(account?.delegatedAccess?.errorFields?.disconnect);
    return [
    createBaseMenuItem(delegatePersonalDetails, error, {
    onSelected: () => {
    if (isOffline) {
    close(showOfflineModal);
    return;
    }
    if (isTrackingGPS) {
    close(() => showGpsInProgressModal(() => disconnect({stashedCredentials, stashedSession})));
    return;
    }
    disconnect({stashedCredentials, stashedSession});
    },
    }),
    currentUserMenuItem,
    ];
    }
    const delegatorMenuItems: PopoverMenuItem[] = sortAlphabetically(
    delegators
    .filter(({email}) => email !== currentUserPersonalDetails.login)
    .map(({email, role}) => {
    const errorFields = account?.delegatedAccess?.errorFields ?? {};
    const error = getLatestError(errorFields?.connect?.[email]);
    const personalDetails = getPersonalDetailByEmail(email);
    return createBaseMenuItem(personalDetails, error, {
    badgeText: translate('delegate.role', {role}),
    onSelected: () => {
    if (isOffline) {
    close(showOfflineModal);
    return;
    }
    if (isTrackingGPS) {
    close(() => showGpsInProgressModal(() => connect({email, delegatedAccess: account?.delegatedAccess, credentials, session, activePolicyID})));
    return;
    }
    connect({email, delegatedAccess: account?.delegatedAccess, credentials, session, activePolicyID});
    },
    });
    }),
    'text',
    localeCompare,
    );
    return [currentUserMenuItem, ...delegatorMenuItems];

    Pass a Find member SearchBar via aboveListContent (label: workspace.people.findMember), with shouldShowIcon={false} so it matches the no-icon Find member look used by table filter bars. Clear the query in hideDelegatorMenu. Important detail: include the current-user row in the searchable set, so searching does not leave the selected account stuck on screen when it does not match.

    Rough shape:

    const searchableMenuItems = [currentUserMenuItem, ...delegatorMenuItems];
    const shouldShowSearchInput = !isActingAsDelegate && delegatorMenuItems.length >= CONST.STANDARD_LIST_ITEM_LIMIT;
    const [searchInput, setSearchInput, filteredMenuItems] = useSearchResults(searchableMenuItems, filterDelegator);
    
    // PopoverMenu
    aboveListContent={
      shouldShowSearchInput ? (
        <SearchBar
          label={translate('workspace.people.findMember')}
          inputValue={searchInput}
          onChangeText={setSearchInput}
          shouldShowEmptyState={filteredMenuItems.length === 0 && searchInput.length > 0}
          shouldShowIcon={false}
        />
      ) : undefined
    }
    1. On CopilotPage, combine displayed delegators + delegates (skip optimistic delegate placeholders) into one tagged list. Gate one Find member SearchBar on the combined count >= CONST.STANDARD_LIST_ITEM_LIMIT, filter with tokenizedSearch, then split results back into the two sections. Hide a section when it has no matches, show the empty state when both are empty, keep Add copilot outside the filter:

    const delegateMenuItems: MenuItemProps[] = useMemo(() => {
    const sortedDelegates = sortAlphabetically(
    delegates.filter((d) => !d.optimisticAccountID).map((d) => ({...d, sortKey: personalDetailsByLogin[d.email.toLowerCase()]?.displayName ?? formatPhoneNumber(d.email)})),
    'sortKey',
    localeCompare,
    );
    return sortedDelegates.map(({email, role, pendingAction, pendingFields}) => {
    const personalDetail = personalDetailsByLogin[email.toLowerCase()];
    const addDelegateErrors = errorFields?.addDelegate?.[email];
    const error = getLatestError(addDelegateErrors);
    const isOwnerRow = isAgentAccount && !!actingDelegateEmail && email.toLowerCase() === actingDelegateEmail;
    const onPress = (e: GestureResponderEvent | KeyboardEvent) => {
    if (isEmptyObject(pendingAction)) {
    showPopoverMenu(e, {email, role});
    return;
    }
    if (!role) {
    Navigation.navigate(ROUTES.SETTINGS_DELEGATE_ROLE.getRoute(email));
    return;
    }
    if (pendingFields?.role && !pendingFields?.email) {
    Navigation.navigate(ROUTES.SETTINGS_UPDATE_DELEGATE_ROLE.getRoute(email, role));
    return;
    }
    Navigation.navigate(ROUTES.SETTINGS_DELEGATE_CONFIRM.getRoute(email, role));
    };
    const formattedEmail = formatPhoneNumber(email);
    const titleText = personalDetail?.displayName ?? formattedEmail;
    const descriptionText = personalDetail?.displayName ? formattedEmail : '';
    return {
    key: email,
    titleComponent: renderTitleWithRole(titleText, descriptionText, role),
    avatarID: personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID,
    icon: personalDetail?.avatar ?? (personalDetail ? getDefaultAvatarURL({accountID: personalDetail.accountID, accountEmail: email}) : undefined),
    iconType: CONST.ICON_TYPE_AVATAR,
    wrapperStyle: [styles.sectionMenuItemTopDescription],
    iconRight: isOwnerRow ? undefined : icons.ThreeDots,
    shouldShowRightIcon: !isOwnerRow,
    pendingAction,
    shouldForceOpacity: !!pendingAction,
    onPendingActionDismiss: () => clearDelegateErrorsByField({email, fieldName: 'addDelegate', delegatedAccess: account?.delegatedAccess}),
    error,
    onPress: isOwnerRow ? undefined : onPress,
    interactive: !isOwnerRow,
    success: selectedEmail === email,
    sentryLabel: CONST.SENTRY_LABEL.SETTINGS_SECURITY.DELEGATE_ITEM,
    };
    });
    }, [
    delegates,
    errorFields,
    account?.delegatedAccess,
    formatPhoneNumber,
    personalDetailsByLogin,
    styles,
    selectedEmail,
    icons.ThreeDots,
    localeCompare,
    showPopoverMenu,
    renderTitleWithRole,
    isAgentAccount,
    actingDelegateEmail,
    ]);
    const sortedDelegators = sortAlphabetically(
    delegators.map((d) => ({...d, sortKey: personalDetailsByLogin[d.email.toLowerCase()]?.displayName ?? formatPhoneNumber(d.email)})),
    'sortKey',
    localeCompare,
    );
    const delegatorMenuItems: MenuItemProps[] = sortedDelegators.map(({email, role, pendingAction}) => {
    const personalDetail = personalDetailsByLogin[email.toLowerCase()];
    const formattedEmail = formatPhoneNumber(email);
    const connectError = getLatestError(errorFields?.connect?.[email]);
    const removeDelegatorError = getLatestError(errorFields?.removeDelegator?.[email]);
    const error = getLatestError({...connectError, ...removeDelegatorError});
    const isCurrentUser = email === session?.email;
    const isPending = !!pendingAction;
    const titleText = personalDetail?.displayName ?? formattedEmail;
    const descriptionText = personalDetail?.displayName ? formattedEmail : '';
    return {
    key: email,
    titleComponent: renderTitleWithRole(titleText, descriptionText, role),
    avatarID: personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID,
    icon: personalDetail?.avatar ?? (personalDetail ? getDefaultAvatarURL({accountID: personalDetail.accountID, accountEmail: email}) : undefined),
    iconType: CONST.ICON_TYPE_AVATAR,
    wrapperStyle: [styles.sectionMenuItemTopDescription],
    disabled: isPending || isCurrentUser,
    onPress: (e: GestureResponderEvent | KeyboardEvent) => {
    showDelegatorPopoverMenu(e, {email, role});
    },
    pendingAction,
    shouldForceOpacity: !!pendingAction,
    error,
    onPendingActionDismiss: () => {
    clearDelegateErrorsByField({email, fieldName: 'connect', delegatedAccess: account?.delegatedAccess});
    clearDelegateErrorsByField({email, fieldName: 'removeDelegator', delegatedAccess: account?.delegatedAccess});
    },
    iconRight: icons.ThreeDots,
    shouldShowRightIcon: !isCurrentUser,
    success: selectedEmail === email,
    sentryLabel: CONST.SENTRY_LABEL.SETTINGS_SECURITY.DELEGATOR_ITEM,
    };
    });

    {hasDelegators && (
    <>
    <Text style={[styles.textLabelSupporting, styles.pv1]}>{translate('delegate.youCanAccessTheseAccounts')}</Text>
    <MenuItemList menuItems={delegatorMenuItems} />
    </>
    )}
    {hasDelegates && (
    <>
    <Text style={[styles.textLabelSupporting, styles.pv1, hasDelegators && styles.mt5]}>{translate('delegate.membersCanAccessYourAccount')}</Text>
    <MenuItemList menuItems={delegateMenuItems} />
    </>
    )}

    1. Small SearchBar tweak: optional shouldShowIcon (default true) so Copilot can hide the magnifying glass without changing other SearchBar callers. Domain members / categories already look like this via Table.FilterBar, which never passes an icon.

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

    Test Branch

    https://github.com/Expensify/App/compare/main...samranahm:96225-copilot-search-above-list-content?expand=1

    Solution Verification Result

    Kapture.2026-07-31.at.18.26.46.mp4
  10. abbasifaizan70 commented on Jul 15, 2026

    @abbasifaizan70
    Contributor

    Note — how this proposal differs from the existing ones on this issue:

    • It does not modify the legacy PopoverMenu at all — unlike the proposals that add search props to it (which require editing its hand-maintained React.memo comparator, re-syncing its index-based arrow-key focus on every keystroke, and scoping the filter away from sub-menus).
    • It does not migrate the switcher to PopoverMenu v2.
    • Its switcher solution is grounded in a production precedent no other proposal cites: CategoryPickerModal already renders a threshold-searchable SelectionList inside PopoverWithMeasuredContent — which directly refutes the objection that "no compact anchored popover in the app hosts a SelectionList".
    • It covers both surfaces from the scope clarification (quick switcher + Copilots page) with the exact thresholds stated there: delegators >= 12 for the switcher, and the combined to/from count >= 12 for the Copilots page — matching the single "Find member" field shown in the design screenshots.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Per the issue and the scope clarification in #96225 (comment), a "Find member" quick search filter must appear in two places once the 12-copilot threshold is met:

    1. The Copilot quick switcher (the "Switch accounts:" popover) — when the user can access at least 12 copilot accounts.
    2. The Copilots page — when there are 12 or more copilots with access to/from other accounts (both sections combined).

    Today neither surface ever shows a search input, no matter how long the lists get.

    What is the root cause of that problem?

    The two surfaces render their lists through components that have no search capability, and neither applies the app-wide CONST.STANDARD_LIST_ITEM_LIMIT (= 12) convention:

    • The quick switcher (AccountSwitcher) builds its rows in menuItems() and hands the full unfiltered array to the legacy PopoverMenu:

      {!!canSwitchAccounts && (
      <PopoverMenu
      isVisible={shouldShowDelegatorMenu}
      onClose={hideDelegatorMenu}
      onItemSelected={hideDelegatorMenu}
      anchorRef={buttonRef}
      anchorPosition={CONST.POPOVER_ACCOUNT_SWITCHER_POSITION}
      anchorAlignment={{
      horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
      vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
      }}
      menuItems={menuItems()}
      headerText={translate('delegate.switchAccount')}
      containerStyles={[{maxHeight: windowHeight / 2}, styles.mw100, shouldUseNarrowLayout ? {} : styles.wFitContent]}
      headerStyles={styles.pt0}
      innerContainerStyle={styles.pb0}
      shouldUseScrollView
      shouldUpdateFocusedIndex={false}
      enableEdgeToEdgeBottomSafeAreaPadding
      shouldShowRadioButton
      />
      )}

      PopoverMenu's body renders only the header text, the optional sub-menu back row, and the menu rows — there is no text input anywhere in the component:

      <PopoverMenuContent
      shouldUseScrollView={shouldUseScrollView}
      contentContainerStyle={[scrollViewPaddingStyles, restScrollContainerStyle]}
      addBottomSafeAreaPadding={enableEdgeToEdgeBottomSafeAreaPadding}
      >
      {renderHeaderText()}
      {enteredSubMenuIndexes.length > 0 && renderBackButtonItem()}
      {renderedMenuItems}
      </PopoverMenuContent>

    • The Copilots page builds delegatorMenuItems/delegateMenuItems and renders both through plain MenuItemLists, with no size check or filter:

      {hasDelegators && (
      <>
      <Text style={[styles.textLabelSupporting, styles.pv1]}>{translate('delegate.youCanAccessTheseAccounts')}</Text>
      <MenuItemList menuItems={delegatorMenuItems} />
      </>
      )}
      {hasDelegates && (
      <>
      <Text style={[styles.textLabelSupporting, styles.pv1, hasDelegators && styles.mt5]}>{translate('delegate.membersCanAccessYourAccount')}</Text>
      <MenuItemList menuItems={delegateMenuItems} />
      </>
      )}

    The 12-item search convention lives in SelectionList consumers (e.g. CategoryPicker/index.tsx gates shouldShowTextInput on categoriesCount >= CONST.STANDARD_LIST_ITEM_LIMIT), and neither copilot surface is on that path:

    STANDARD_LIST_ITEM_LIMIT: 12,

    What changes do you think we should make in order to solve the problem?

    Reuse the two search patterns that already ship in production, one per surface, with zero changes to the shared PopoverMenu.

    Surface 1 — quick switcher: reuse the anchored-popover + SelectionList pattern that CategoryPickerModal already ships.

    The main objection raised against a SelectionList here is that "no compact anchored popover in the app hosts a SelectionList" — but one does, in production: CategoryPickerModal renders the threshold-searchable category picker inside PopoverWithMeasuredContent:

    <PopoverWithMeasuredContent
    anchorRef={anchorRef}
    isVisible={isVisible}
    onClose={onClose}
    anchorPosition={anchorPosition}
    popoverDimensions={popoverDimensions}
    anchorAlignment={anchorAlignment}
    innerContainerStyle={StyleUtils.getWidthStyle(popoverDimensions.width)}
    restoreFocusType={CONST.MODAL.RESTORE_FOCUS_TYPE.DELETE}
    shouldSwitchPositionIfOverflow
    shouldEnableNewFocusManagement
    shouldMeasureAnchorPositionFromTop={shouldMeasureAnchorPositionFromTop}
    shouldSkipRemeasurement
    shouldDisplayBelowModals
    >
    <View style={[StyleUtils.getHeight(popoverDimensions.height), styles.flexColumn, styles.pt4]}>
    <CategoryPicker

    <SelectionListWithSections
    sections={sections}
    onSelectRow={onSubmit}
    ListItem={SingleSelectListItem}
    shouldShowTextInput={categoriesCount >= CONST.STANDARD_LIST_ITEM_LIMIT}

    Apply the same pattern to the switcher: keep the existing trigger, anchor position, and maxHeight: windowHeight / 2 cap, and render the account list with a SelectionList inside PopoverWithMeasuredContent instead of PopoverMenu:

    • Map the same rows menuItems() builds today (pinned current-user radio row + alphabetized delegators with avatar, Full/Limited role badge, and connect-error red dot) onto the shared list-item model.
    • Gate the input on the clarified threshold: shouldShowTextInput={delegators.length >= CONST.STANDARD_LIST_ITEM_LIMIT}, with textInputOptions using the existing workspace.people.findMember ("Find member") string from the design, filtering by display name + login via tokenizedSearch, and the standard common.noResultsFound header message.
    • Move the existing onSelected behavior (connect/disconnect, offline modal, GPS-in-progress confirmation) into onSelectRow unchanged. The acting-as-delegate branch (max 2 rows) never reaches the threshold and stays as-is. The query resets naturally because the popover content unmounts on close.

    This gets search, filtering, empty state, and keyboard navigation over the filtered list for free from SelectionList, and leaves PopoverMenu byte-for-byte untouched for its many other consumers — no new props, no edits to its hand-maintained React.memo comparator (L735–L754), and no manual re-syncing of its index-based arrow-key focus while filtering.

    Surface 2 — Copilots page: one combined "Find member" SearchBar.

    The page already builds sortedDelegators (L270–274) and sortedDelegates (L204–208, which already excludes optimistic placeholders). Combine both into one tagged collection and pipe it through the existing useSearchResults hook (debounce + auto-reset below the limit built in, L36–L41) with tokenizedSearch on display name + email:

    • Show a single SearchBar (label: workspace.people.findMember, matching the design screenshots) when sortedDelegators.length + sortedDelegates.length >= CONST.STANDARD_LIST_ITEM_LIMIT — the "access to/from other accounts" combined threshold from the scope comment.
    • Partition the filtered results back into the two existing sections; hide a section header while its filtered list is empty; show the standard no-results state when both are; keep the "Add copilot" row outside the filter.

    Frontend-only; no Onyx shape, API, or navigation changes.

    How this differs from the other proposals on this issue: it changes neither the legacy PopoverMenu (no new search props, no memo-comparator edits, no focus-index re-syncing) nor migrates to PopoverMenu v2 — it reuses the already-shipping CategoryPickerModal anchored-SelectionList precedent for the switcher, and covers the clarified second surface with the standard SearchBar + useSearchResults idiom.

    Test branch

    Link

    Demo

    Screen.Recording.2026-07-16.at.6.32.25.PM.mov
  11. melvin-bot commented on Jul 15, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 (External)

  12. changed the title [-]Copilot quick switcher is missing search input when the list contains more than 12 copilots[/-] [+][$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots[/+] on Jul 15, 2026
  13. 137 remaining items

  14. expensify-chore-bot commented on Nov 16, 2026

    @expensify-chore-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. changed the title [-][Due for payment 2026-09-30] [$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots[/-] [+][$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots[/+] on Nov 16, 2026
  16. removed their assignment
    on Nov 16, 2026
  17. mallenexpensify commented on Nov 16, 2026

    @mallenexpensify
    Contributor

    Please comment and tag me if/when payment is due, thx

  18. changed the title [-][$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots[/-] [+][Due for payment 2026-11-28] [$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots[/+] on Nov 21, 2026
  19. melvin-bot commented on Nov 21, 2026

    @melvin-bot

    @eh2077

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.5.51-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-11-28. 🎊

    The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]

  20. changed the title [-][Due for payment 2026-11-28] [$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots[/-] [+][$250] Copilot quick switcher is missing search input when the list contains more than 12 copilots[/+] on Nov 21, 2026
  21. mallenexpensify commented on Nov 21, 2026

    @mallenexpensify
    Contributor

    Please comment and tag me if/when payment is due, thx

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorOverdue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions