Skip to content

[Due for payment 2026-08-10] [$250] Spends - feed:xxxx auto selected to Bank Account instead of Expensify Card #96342

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: undefined
Reproducible in staging?: Yes
Reproducible in production?: https://github.com/Expensify/Expensify/issues/557015
If this was caught during regression testing, add the test name, ID and link from BrowserStack: undefined
Email or phone of affected tester (no customers): undefined
Issue reported by: Applause Internal Team
Bug source: undefined
Device used: undefined
App Component: undefined

Action Performed:

Precondition:
Workspace is set up with Expensify Card feature.
Assign at least one card to any user.

Steps:

  1. Open the app
  2. Go to Spends
  3. Click Card accruals

Expected Result:

search query shows "feed:Expensify Card"

Actual Result:

feed:xxxx auto selected to Region Bank instead of Expensify Card

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7194129_1782724488033.expensify_card.mp4

View all open jobs on GitHub

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

Activity

  1. added
    Daily
    Bug
    on Jul 16, 2026
  2. ijmalik commented on Jul 16, 2026

    @ijmalik
    Contributor

    Proposal

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

    On the Spends (Reports) page, clicking the "Card accruals" suggested search auto-fills the query with the account's company card feed (e.g. feed:Region Bank) instead of the workspace's Expensify Card feed, even though the workspace has the Expensify Card set up with assigned cards.

    What is the root cause of that problem?

    In src/hooks/useSearchTypeMenuSections.ts (line 111, against origin/main), the feed passed to createTypeMenuSections is defaultCardFeed: defaultCardFeed ?? defaultExpensifyCard, where defaultCardFeed comes from useCardFeedsForDisplay() which only aggregates company card feeds from SHARED_NVP_PRIVATE_DOMAIN_MEMBER — Expensify Card feeds are never part of that list (they are derived separately via defaultExpensifyCardSelector in src/selectors/Card.ts:78). Because of the nullish coalescing, whenever the account has any company card feed (Region Bank here), it always wins and the Expensify Card feed is only ever used when there are zero company feeds. That feed ID then flows into getSuggestedSearches → the UNAPPROVED_CARD item's feed: [defaultFeedID] (src/libs/SearchUIUtils.ts:914), producing feed:Region Bank in the query.

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

    In src/hooks/useSearchTypeMenuSections.ts:111, swap the precedence so the workspace's Expensify Card feed is preferred when one exists:

    defaultCardFeed: defaultExpensifyCard ?? defaultCardFeed,

    The same fallback should also be applied in src/components/Search/SearchQueryProvider.tsx:44-47, which currently calls getSuggestedSearches(accountID, defaultCardFeedID) using only useCardFeedsForDisplay()'s company feed with no Expensify Card fallback at all — leaving it inconsistent would make the suggested-search hashes computed there (used for matching/highlighting the active suggested search) disagree with the menu items built in useSearchTypeMenuSections, so "Card accruals" would stop being recognized as the active tab. No API/backend change is involved — the feed: filter already accepts Expensify Card feed IDs (the same IDs built by getExpensifyCardFeedsForDisplay in src/libs/CardFeedUtils.ts:152 are already selectable in the search feed filter).

    What alternative solutions did you explore? (Optional)

    Merging Expensify Card feeds into cardFeedsByPolicy inside useCardFeedsForDisplay/getDefaultCardFeed so alphabetical/policy-priority sorting picks them naturally — rejected because that hook feeds other company-card-only UI and the refactor is much larger than needed for this bug.

  3. MelvinBot commented on Jul 16, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The Card accruals item under Spends is the UNAPPROVED_CARD suggested search. Its query hard-codes a single feed: value, and that value is picked from the wrong source, so it lands on a company-card feed (e.g. Region Bank) instead of the Expensify Card.

    The feed passed into the suggested search is defaultCardFeed ?? defaultExpensifyCard at src/hooks/useSearchTypeMenuSections.ts:111. The problem is that defaultCardFeed never contains the Expensify Card — by design, getCardFeedsForDisplayPerPolicy excludes Expensify Card feeds (src/libs/CardFeedUtils.ts:227). So as soon as the workspace has any company-card feed, defaultCardFeed is truthy, the ?? short-circuits, and defaultExpensifyCard is never used. The Expensify Card can only be selected when there are zero company feeds.

    That is why the tester — who has both an Expensify Card and a Region Bank company feed — gets feed:Region Bank rather than feed:Expensify Card.

    Evidence / code path
    1. UNAPPROVED_CARD search query is built with feed: defaultFeedID ? [defaultFeedID] : [''] — src/libs/SearchUIUtils.ts:907-917, where defaultFeedID = defaultCardFeed?.id (passed at SearchUIUtils.ts:4605).
    2. The defaultCardFeed given to createTypeMenuSections is defaultCardFeed ?? defaultExpensifyCard — useSearchTypeMenuSections.ts:111.
    3. getDefaultCardFeed returns the alphabetically-first company feed and only falls through to commercial feeds — it has no notion of the Expensify Card — useCardFeedsForDisplay.ts:26-56.
    4. getCardFeedsForDisplayPerPolicy explicitly notes "Expensify Card feeds are not included (handled by the Expensify card selector)" — CardFeedUtils.ts:227.

    So the ?? fallback is effectively backwards: it prefers the (non-Expensify) company feed and treats the Expensify Card as the last resort.

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

    For the Card accruals (UNAPPROVED_CARD) default feed, prefer the Expensify Card when the workspace has Expensify Cards enabled — i.e. flip the fallback order so defaultExpensifyCard wins over defaultCardFeed at useSearchTypeMenuSections.ts:111, or pass a dedicated default feed for the accruals search rather than reusing the general company-card default.

    ⚠️ One thing worth confirming before implementing: which feed should be the default here is a product decision. The current defaultCardFeed ?? defaultExpensifyCard ordering looks intentional (Expensify Card as fallback), so please confirm the intended default is Expensify Card when both exist — the fix is a one-line reorder either way, but the expected behavior should be nailed down first.

    What alternative solutions did you explore? (Optional)

    Leave the feed unset (feed: ['']) so Card accruals shows all card feeds and the user picks — but that changes the current single-feed UX and likely isn't what's wanted.

    Possibly related (not duplicates)
    • Expensify/App#91790 — [Exploratory] Spend-Card accruals highlight disappears after changing filters — same Card accruals area but about highlight/selection state, not the feed default.

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

  4. added
    External
    on Jul 16, 2026
  5. added
    Help Wanted
    on Jul 16, 2026
  6. David-2002065 commented on Jul 16, 2026

    @David-2002065
    Contributor

    Note for the reviewer: this proposal was auto-withdrawn by ProposalPolice as a suspected duplicate — it isn't one. It was posted right after the External assignment, and the auto-withdrawal is a false positive: the earlier proposals all stop at the ?? precedence and suggest flipping it to defaultExpensifyCard ?? defaultCardFeed. That flip is itself buggy for the reason below (global vs active-policy scoping), so this proposal identifies a different root cause and a different fix. Re-posting so the distinct approach stays on record.

    Proposal

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

    On the Spends page, opening the Card accruals suggested search builds a query whose feed: filter auto-selects a company/bank card feed (e.g. feed:Region Bank) instead of the workspace's Expensify Card feed. On a workspace that runs the Expensify Card, the expected query is feed:Expensify Card.

    What is the root cause of that problem?

    The Card accruals (UNAPPROVED_CARD) search takes its feed from a single pre-merged value built here:

    createTypeMenuSections({
    currentUserEmail: currentUserLoginAndAccountID?.email,
    currentUserAccountID: currentUserLoginAndAccountID?.accountID,
    cardFeedsByPolicy,
    defaultCardFeed: defaultCardFeed ?? defaultExpensifyCard,

    The value passed as defaultCardFeed is defaultCardFeed ?? defaultExpensifyCard. Because a company feed (Region Bank) is truthy whenever it exists, the ?? short-circuits and the Expensify Card is only ever used on workspaces that have zero company feeds. That merged id flows through createTypeMenuSections → getSuggestedSearches and becomes the feed: of Card accruals:

    [CONST.SEARCH.SEARCH_KEYS.UNAPPROVED_CARD]: {
    key: CONST.SEARCH.SEARCH_KEYS.UNAPPROVED_CARD,
    translationPath: 'search.tabs.unapprovedCard',
    type: CONST.SEARCH.DATA_TYPES.EXPENSE,
    icon: 'CreditCardHourglass',
    searchQuery: buildQueryStringFromFilterFormValues({
    type: CONST.SEARCH.DATA_TYPES.EXPENSE,
    feed: defaultFeedID ? [defaultFeedID] : [''],
    groupBy: CONST.SEARCH.GROUP_BY.CARD,
    status: [CONST.SEARCH.STATUS.EXPENSE.UNREPORTED, CONST.SEARCH.STATUS.EXPENSE.DRAFTS, CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING],
    }),

    So far this matches what others noticed. But the important part — and why simply flipping the ?? is wrong — is that the two operands are resolved with different scoping:

    • defaultCardFeed is active-policy-scoped. getDefaultCardFeed prioritizes the active policy's feeds, and only falls through to other eligible/commercial feeds:

      function getDefaultCardFeed(
      eligiblePoliciesIDsArray: string[] | undefined,
      activePolicyID: string | undefined,
      cardFeedsByPolicy: Record<string, CardFeedForDisplay[]>,
      localeCompare: (a: string, b: string) => number,
      ): CardFeedForDisplay | undefined {
      const eligiblePoliciesIDs = new Set(eligiblePoliciesIDsArray);
      // Prioritize the active policy if eligible
      if (activePolicyID && eligiblePoliciesIDs.has(activePolicyID)) {
      const policyCardFeeds = cardFeedsByPolicy[activePolicyID];
      if (policyCardFeeds?.length) {
      return [...policyCardFeeds].sort((a, b) => localeCompare(a.name, b.name)).at(0);
      }
      }
      // If the active policy doesn't have card feeds, use the first eligible policy that does
      for (const eligiblePolicyID of eligiblePoliciesIDs) {
      const policyCardFeeds = cardFeedsByPolicy[eligiblePolicyID];
      if (policyCardFeeds?.length) {
      return [...policyCardFeeds].sort((a, b) => localeCompare(a.name, b.name)).at(0);
      }
      }
      // Commercial feeds don't have preferred policies, so we need to include these in the list
      const commercialFeeds = Object.values(cardFeedsByPolicy)
      .flat()
      .filter((feed) => !isCustomFeed(feed.name as CardFeedWithNumber));
      return commercialFeeds.sort((a, b) => localeCompare(a.name, b.name)).at(0);
      }

    • defaultExpensifyCard is global. Its selector picks the first non-travel Expensify Card feed across the entire NON_PERSONAL_AND_WORKSPACE_CARD_LIST — every workspace the user belongs to, with no active-policy notion:

      const defaultExpensifyCardSelector = (allCards: OnyxEntry<NonPersonalAndWorkspaceCardListDerivedValue>) => {
      const cards = Object.values(getExpensifyCardFeedsForDisplay(allCards ?? undefined, undefined));
      return cards.find((feed) => feed.country !== CONST.TRAVEL.PROGRAM_TRAVEL_US);
      };

    That mismatch is the real root cause. A blanket defaultExpensifyCard ?? defaultCardFeed flip would fix the reported case but silently regress a mixed setup: a user whose active workspace uses company cards, but who also belongs to another workspace with an Expensify Card, would get that other workspace's Expensify Card injected into Card accruals. The feed must be resolved for the relevant policy, not merely preferred by truthiness.

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

    Stop pre-merging in the hook, and resolve a dedicated Card-accruals feed that prefers the Expensify Card only when the active policy actually runs the Expensify Card program, falling back to the company feed otherwise.

    In useSearchTypeMenuSections, compute the accruals feed explicitly instead of the ?? merge:

    // prefer the Expensify Card feed only when the active workspace runs the Expensify Card
    const activePolicyHasExpensifyCard = !!allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`]?.areExpensifyCardsEnabled;
    const unapprovedCardFeedID = activePolicyHasExpensifyCard && defaultExpensifyCard ? defaultExpensifyCard.id : defaultCardFeed?.id;

    Pass defaultCardFeed unchanged (drop the ?? defaultExpensifyCard) and thread unapprovedCardFeedID through to getSuggestedSearches, which uses it for the UNAPPROVED_CARD item only:

    function getSuggestedSearches(
        accountID: number = CONST.DEFAULT_NUMBER_ID,
        defaultFeedID?: string,
        shouldShowExpensifyCard?: boolean,
        unapprovedCardFeedID?: string,
    ): Record<ValueOf<typeof CONST.SEARCH.SEARCH_KEYS>, SearchTypeMenuItem> {
    // UNAPPROVED_CARD
    feed: unapprovedCardFeedID ? [unapprovedCardFeedID] : [''],

    STATEMENTS stays on defaultFeedID (the company feed), so its behaviour is unchanged. The same unapprovedCardFeedID must also be computed and passed in SearchQueryProvider, which builds the suggested searches a second time — otherwise its similarSearchHash won't match the menu item and the Card accruals tile won't highlight as active:

    const {defaultCardFeed} = useCardFeedsForDisplay();
    const {accountID} = useCurrentUserPersonalDetails();
    const defaultCardFeedID = defaultCardFeed?.id;
    const suggestedSearches = getSuggestedSearches(accountID, defaultCardFeedID);

    To keep the two call sites from drifting, the resolution can live in one small helper next to getDefaultCardFeed and be called from both.

    What specific scenarios should we cover in automated tests to prevent this from happening again?

    Unit-test the UNAPPROVED_CARD query from getSuggestedSearches:

    • Active policy has Expensify Card + a company feed exists → feed is the Expensify Card feed id (the issue's expected result).
    • Active policy has only a company feed → feed is the company feed id.
    • Active policy is company-card-only but another workspace has an Expensify Card → feed is the active workspace's company feed, not the other workspace's Expensify Card (guards the scoping regression the naive ?? flip introduces).
    • No card feeds at all → feed is [''].

    What alternative solutions did you explore? (Optional)

    Flipping the merge to defaultExpensifyCard ?? defaultCardFeed at useSearchTypeMenuSections.ts:111. Rejected: it fixes the single-workspace case but regresses the multi-workspace case above, because defaultExpensifyCard is global while defaultCardFeed is active-policy-scoped. Including Expensify Card feeds inside getCardFeedsForDisplayPerPolicy so getDefaultCardFeed returns one was also rejected — that exclusion is intentional and shared by the company-cards admin selectors, so it has a wide blast radius for a one-search bug.

  7. yusufdeveloper2903 commented on Jul 16, 2026

    @yusufdeveloper2903
    Contributor

    Proposal

    What is the root cause of that problem?

    When building the feed:xxxx search query for Card Accruals, the code that selects which card feed to use likely picks the first feed from the list of available card feeds without prioritizing the Expensify Card feed over regular bank account feeds. This means if a bank/region feed appears before the Expensify Card feed in the data structure, it gets selected instead.

    The relevant logic is likely in src/libs/SearchQueryUtils.ts (or a similar query-building utility) where card feeds are resolved to a feed identifier.

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

    When selecting the default card feed for the feed:xxxx query, we should prioritize feeds whose key/type indicates an Expensify Card (e.g., feed key starts with Expensify or matches CONST.EXPENSIFY_CARD.BANK / CONST.EXPENSIFY_CARD_BANK_NAME) over other bank feeds.

    - const defaultFeed = Object.keys(cardFeeds)[0];
    + const expensifyCardFeed = Object.keys(cardFeeds).find(
    +     feed => feed.startsWith('Expensify') || feed === CONST.EXPENSIFY_CARD.BANK
    + );
    + const defaultFeed = expensifyCardFeed ?? Object.keys(cardFeeds)[0];

    This ensures the Expensify Card feed is preferred when constructing the search query, falling back to the first available feed only if no Expensify Card feed exists.

    What alternative solutions did you explore?

    I considered sorting feeds so Expensify Card always comes first universally, but that could have unintended side effects in other places that rely on feed ordering. A targeted fix at query-construction time is safer and more explicit.

  8. aswin-s commented on Jul 16, 2026

    @aswin-s
    Contributor

    Note: This proposal is not a duplicate. It changes a different location in the code to address the issue.

    Proposal

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

    On Web, when a workspace has both an Expensify Card feed (with at least one card assigned to a user) and a commercial/bank card feed (e.g. Region Bank), navigating to Spends → Card accruals populates the search with feed:<bank-feed-id> (Region Bank) instead of feed:Expensify Card. Expected: the Card accruals suggested search should default the feed to the workspace's Expensify Card feed when the user has assigned Expensify cards.

    What is the root cause of that problem?

    The feed: value for the "Card accruals" (UNAPPROVED_CARD) suggested search is built in src/libs/SearchUIUtils.ts:914 as feed: defaultFeedID ? [defaultFeedID] : [''], where defaultFeedID is defaultCardFeed?.id from useCardFeedsForDisplay (src/components/Search/SearchQueryProvider.tsx:47 and src/libs/SearchUIUtils.ts:4605). The producer of that id, getDefaultCardFeed in src/hooks/useCardFeedsForDisplay.ts:26-56, picks the first feed of the active/eligible policy strictly by localeCompare(name) (lines 38, 46, 55) and never prefers an Expensify Card feed over a commercial bank feed — even though defaultExpensifyCard is already computed separately and passed alongside (SearchUIUtils.ts:4605, gating card-accrual visibility at line 1116). So when the active policy has both an Expensify Card feed and a bank feed, whichever sorts first by name wins, which is why "Region Bank" is auto-selected instead of "Expensify Card".

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

    1. In src/hooks/useCardFeedsForDisplay.ts (getDefaultCardFeed, lines 26–56), when iterating the active policy's feeds (lines 35–40) and the eligible-policy fallback (lines 43–48), prefer an Expensify Card feed (detectable via the existing CardUtils helpers used for Expensify feed types) over commercial/bank feeds before falling back to the alphabetical localeCompare tiebreak.
    2. Alternatively (or additionally), in src/libs/SearchUIUtils.ts:4605, when defaultExpensifyCard exists for the current context, pass defaultExpensifyCard.id (not defaultCardFeed?.id) as the defaultFeedID to getSuggestedSearches for the UNAPPROVED_CARD key, so the Card accruals suggestion always seeds with the Expensify Card feed when one is available.
    3. Update getSuggestedSearches in [src/libs/SearchUIUtils.ts:722](https://github.com/Expensify/App/blob/d769fd57fb65190d73383950d7120d6f6189717e/src/libs/SearchUIUtils.ts#L722)–930 to accept a distinct defaultExpensifyCardFeedID (or reuse defaultExpensifyCard) and use it at line 914 for the UNAPPROVED_CARD entry, keeping defaultFeedID for the statements entry at line 866 unchanged.
    4. Add a unit test around getDefaultCardFeed / getSuggestedSearches[UNAPPROVED_CARD].searchQuery covering the "policy has both Expensify Card feed and bank feed" case, asserting the resulting query contains the Expensify Card feed id.

    What alternative solutions did you explore? (Optional)

  9. abbasifaizan70 commented on Jul 16, 2026

    @abbasifaizan70
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-20 13:34:52 UTC.

    Proposal (updated)

    Updated per @joekaufmanexpensify's confirmation of the expected behavior. Two additions vs. my earlier proposal: I now also update the second getSuggestedSearches call site (SearchQueryProvider) so the tab still highlights, and I scope the Expensify Card to the active workspace to avoid a mixed-workspace regression.

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

    On a workspace that has both a company/bank card feed and the Expensify Card set up, clicking Card accruals from Spends opens a search with the company feed pre-selected (feed:Region Bank) instead of feed:Expensify Card.

    Per @joekaufmanexpensify, the confirmed expected behavior is: Card accruals should default to the active workspace's Expensify Card whenever it is available, even when other third-party feeds exist — consistent with the Classic domains page and NewDot bank reconciliation, which both default to the Expensify Card when present.

    What is the root cause of that problem?

    The Card accruals (UNAPPROVED_CARD) search fills its feed: filter from a single defaultFeedID:

    feed: defaultFeedID ? [defaultFeedID] : ['']   // SearchUIUtils.ts:914
    

    That id comes from defaultCardFeed ?? defaultExpensifyCard in useSearchTypeMenuSections.ts:111. The two operands are not peers: defaultCardFeed is drawn from cardFeedsByPolicy, which by design excludes Expensify Card feeds (getCardFeedsForDisplayPerPolicy, CardFeedUtils.ts — "Expensify Card feeds are not included"). So defaultCardFeed can only ever be a company feed, and the ?? reaches defaultExpensifyCard only when there is no company feed at all. As soon as any company feed exists, it wins — which is the reported bug.

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

    Resolve a dedicated feed id for Card accruals that prefers the active workspace's Expensify Card, and thread it through both places that build the suggested searches so they stay in sync.

    1. Resolve the active workspace's Expensify Card feed id. defaultExpensifyCardSelector (Card.ts:78) is global, so don't use it directly. Pick the Expensify Card feed whose fundID maps to the active policy (the same fundID ↔ policyAccountID linkage getCardFeedsForDisplayPerPolicy already uses for orphan feeds). Call it activeExpensifyCardFeedID.

    2. Prefer it only for UNAPPROVED_CARD. Add a dedicated parameter to getSuggestedSearches and use it for the Card accruals feed, leaving defaultFeedID (the company feed) for the Statements entry unchanged:

      feed: activeExpensifyCardFeedID ? [activeExpensifyCardFeedID] : defaultFeedID ? [defaultFeedID] : ['']
      
    3. Update both call sites so their hashes agree. Pass activeExpensifyCardFeedID from the menu builder (SearchUIUtils.ts:4605) and from SearchQueryProvider.tsx:47, which today passes only the company feed id. Without the second update, the menu item's feed and the provider's computed similarSearchHash disagree, so the Card accruals tab won't highlight as active.

    No API/backend change — the feed: filter already accepts Expensify Card feed ids.

    What specific scenarios should we cover in automated tests to prevent this from happening again?

    • Active workspace has an Expensify Card and a company feed → Card accruals feed is the Expensify Card id (the reported case).
    • Active workspace has only a company feed → feed stays the company feed id.
    • Active workspace is company-only but another workspace has an Expensify Card → feed stays the active workspace's company feed, not the other workspace's Expensify Card (guards the global-scoping regression).
    • No card feeds → feed is [''].
    • The Card accruals tab is recognized as active (its similarSearchHash from SearchQueryProvider matches the menu item).

    What alternative solutions did you explore? (Optional)

    • Flip to defaultExpensifyCard ?? defaultCardFeed. Rejected: fixes the repro but regresses mixed multi-workspace setups, because defaultExpensifyCard is global while defaultCardFeed is active-policy-scoped — a user in a company-card workspace who also belongs to an Expensify-Card workspace would get the wrong workspace's card.
    • Include Expensify Card feeds in getCardFeedsForDisplayPerPolicy / rewrite getDefaultCardFeed. Rejected: that exclusion is intentional and shared by company-card admin UI, so the blast radius is far wider than this one search.
  10. samranahm commented on Jul 16, 2026

    @samranahm
    Contributor

    Proposal

    What is the root cause of that problem?

    When an admin opens Spends and taps the "Card accruals" row, NewDot builds a Search query whose feed: filter is meant to point at the Expensify Card feed. Instead the query resolves to a commercial bank feed (Region Bank), so the header shows feed:xxxx for a bank account rather than feed:Expensify Card.

    The feed used to build the card menu items comes from useSearchTypeMenuSections, which passes defaultCardFeed into createTypeMenuSections with this fallback order:

    const useSearchTypeMenuSections = (queryParams?: UseSearchTypeMenuSectionsParams) => {
    const {hash, similarSearchHash, sortBy, sortOrder, type} = queryParams ?? {};
    const [defaultExpensifyCard] = useOnyx(ONYXKEYS.DERIVED.NON_PERSONAL_AND_WORKSPACE_CARD_LIST, {selector: defaultExpensifyCardSelector});
    const {defaultCardFeed, cardFeedsByPolicy} = useCardFeedsForDisplay();
    const {isOffline} = useNetwork();
    const [allPolicies] = useMappedPolicies(policyMapper);
    const [currentUserLoginAndAccountID] = useOnyx(ONYXKEYS.SESSION, {selector: currentUserLoginAndAccountIDSelector});
    const [savedSearches] = useOnyx(ONYXKEYS.SAVED_SEARCHES);
    const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
    const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});
    const [pendingReportCreation, setPendingReportCreation] = useState<{policyID: string; policyName?: string; onConfirm: (shouldDismissEmptyReportsConfirmation: boolean) => void} | null>(
    null,
    );
    const handlePendingConfirm = useCallback(
    (shouldDismissEmptyReportsConfirmation: boolean) => {
    pendingReportCreation?.onConfirm(shouldDismissEmptyReportsConfirmation);
    setPendingReportCreation(null);
    },
    [pendingReportCreation, setPendingReportCreation],
    );
    const handlePendingCancel = useCallback(() => {
    setPendingReportCreation(null);
    }, [setPendingReportCreation]);
    const {openCreateReportConfirmation} = useCreateEmptyReportConfirmation({
    policyID: pendingReportCreation?.policyID,
    policyName: pendingReportCreation?.policyName ?? '',
    onConfirm: handlePendingConfirm,
    onCancel: handlePendingCancel,
    });
    useEffect(() => {
    if (!pendingReportCreation) {
    return;
    }
    openCreateReportConfirmation();
    }, [pendingReportCreation, openCreateReportConfirmation]);
    const typeMenuSections = useMemo(
    () =>
    createTypeMenuSections({
    currentUserEmail: currentUserLoginAndAccountID?.email,
    currentUserAccountID: currentUserLoginAndAccountID?.accountID,
    cardFeedsByPolicy,
    defaultCardFeed: defaultCardFeed ?? defaultExpensifyCard,
    policies: allPolicies,
    savedSearches,
    isOffline,
    defaultExpensifyCard,
    draftTransactionIDs,
    isTrackIntentUser: isTrackIntentUser ?? false,
    }),
    [
    currentUserLoginAndAccountID?.email,
    currentUserLoginAndAccountID?.accountID,
    cardFeedsByPolicy,
    defaultCardFeed,
    defaultExpensifyCard,
    allPolicies,
    savedSearches,
    isOffline,
    draftTransactionIDs,
    isTrackIntentUser,
    ],
    );
    const activeItemIndex = useMemo(() => {
    const isSavedSearchActive = hash !== undefined && !!savedSearches && Object.keys(savedSearches).some((key) => Number(key) === hash);
    if (isSavedSearchActive) {
    return -1;
    }
    let index = 0;
    for (const section of typeMenuSections) {
    const found = section.menuItems.findIndex((item) => {

    Here defaultCardFeed comes from useCardFeedsForDisplay() and defaultExpensifyCard comes from the NON_PERSONAL_AND_WORKSPACE_CARD_LIST derived selector. Because the value passed is defaultCardFeed ?? defaultExpensifyCard, any generic default card feed (which can be a commercial bank feed such as Region Bank) takes priority over the Expensify Card feed. So on a workspace that has both an assigned Expensify Card and a bank feed, the Expensify-Card-specific accruals item inherits the bank feed, which is why feed: auto-selects Region Bank instead of Expensify Card.

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

    1. In useSearchTypeMenuSections.ts, the Expensify Card accruals item must be built from defaultExpensifyCard, not from the generic defaultCardFeed ?? defaultExpensifyCard value that prefers bank feeds.

    const useSearchTypeMenuSections = (queryParams?: UseSearchTypeMenuSectionsParams) => {
    const {hash, similarSearchHash, sortBy, sortOrder, type} = queryParams ?? {};
    const [defaultExpensifyCard] = useOnyx(ONYXKEYS.DERIVED.NON_PERSONAL_AND_WORKSPACE_CARD_LIST, {selector: defaultExpensifyCardSelector});
    const {defaultCardFeed, cardFeedsByPolicy} = useCardFeedsForDisplay();
    const {isOffline} = useNetwork();
    const [allPolicies] = useMappedPolicies(policyMapper);
    const [currentUserLoginAndAccountID] = useOnyx(ONYXKEYS.SESSION, {selector: currentUserLoginAndAccountIDSelector});
    const [savedSearches] = useOnyx(ONYXKEYS.SAVED_SEARCHES);
    const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
    const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});
    const [pendingReportCreation, setPendingReportCreation] = useState<{policyID: string; policyName?: string; onConfirm: (shouldDismissEmptyReportsConfirmation: boolean) => void} | null>(
    null,
    );
    const handlePendingConfirm = useCallback(
    (shouldDismissEmptyReportsConfirmation: boolean) => {
    pendingReportCreation?.onConfirm(shouldDismissEmptyReportsConfirmation);
    setPendingReportCreation(null);
    },
    [pendingReportCreation, setPendingReportCreation],
    );
    const handlePendingCancel = useCallback(() => {
    setPendingReportCreation(null);
    }, [setPendingReportCreation]);
    const {openCreateReportConfirmation} = useCreateEmptyReportConfirmation({
    policyID: pendingReportCreation?.policyID,
    policyName: pendingReportCreation?.policyName ?? '',
    onConfirm: handlePendingConfirm,
    onCancel: handlePendingCancel,
    });
    useEffect(() => {
    if (!pendingReportCreation) {
    return;
    }
    openCreateReportConfirmation();
    }, [pendingReportCreation, openCreateReportConfirmation]);
    const typeMenuSections = useMemo(
    () =>
    createTypeMenuSections({
    currentUserEmail: currentUserLoginAndAccountID?.email,
    currentUserAccountID: currentUserLoginAndAccountID?.accountID,
    cardFeedsByPolicy,
    defaultCardFeed: defaultCardFeed ?? defaultExpensifyCard,
    policies: allPolicies,
    savedSearches,
    isOffline,
    defaultExpensifyCard,
    draftTransactionIDs,
    isTrackIntentUser: isTrackIntentUser ?? false,
    }),
    [
    currentUserLoginAndAccountID?.email,
    currentUserLoginAndAccountID?.accountID,
    cardFeedsByPolicy,
    defaultCardFeed,
    defaultExpensifyCard,
    allPolicies,
    savedSearches,
    isOffline,
    draftTransactionIDs,
    isTrackIntentUser,
    ],
    );
    const activeItemIndex = useMemo(() => {
    const isSavedSearchActive = hash !== undefined && !!savedSearches && Object.keys(savedSearches).some((key) => Number(key) === hash);
    if (isSavedSearchActive) {
    return -1;
    }
    let index = 0;
    for (const section of typeMenuSections) {
    const found = section.menuItems.findIndex((item) => {

    Today defaultExpensifyCard is already read from the derived card list selector, but it is only used as a fallback. Pass it through as its own argument so createTypeMenuSections can build the Expensify Card accruals query from the Expensify Card feed specifically:

    createTypeMenuSections({
        ...,
        cardFeedsByPolicy,
        defaultCardFeed: defaultCardFeed ?? defaultExpensifyCard,
        defaultExpensifyCard,
        ...
    });
    1. In createTypeMenuSections (inside SearchUIUtils.ts), when constructing the Expensify Card accruals menu item, use the new defaultExpensifyCard argument to build its feed: filter instead of the shared defaultCardFeed.

    https://github.com/Expensify/App/blob/d769fd57fb65190d73383950d7120d6f6189717e/src/libs/SearchUIUtils.ts

    This keeps generic card sections using defaultCardFeed while ensuring the accruals row that is meant for the Expensify Card always resolves to the Expensify Card feed, which fixes the wrong feed:Region Bank selection.

    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.

  11. melvin-bot commented on Jul 16, 2026

    @melvin-bot

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

  12. wildan-m commented on Jul 16, 2026

    @wildan-m
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-16 18:49:34 UTC.

    Proposal

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

    On a workspace that has the Expensify Card feature enabled and at least one card assigned, opening Spends → Card accruals builds a search query that auto-selects a company card feed (e.g. feed:Regions Bank) instead of feed:Expensify Card.

    What is the root cause of that problem?

    The Card accruals suggested search takes its feed straight from the single defaultFeedID argument passed into getSuggestedSearches:

    [CONST.SEARCH.SEARCH_KEYS.UNAPPROVED_CARD]: {
    key: CONST.SEARCH.SEARCH_KEYS.UNAPPROVED_CARD,
    translationPath: 'search.tabs.unapprovedCard',
    type: CONST.SEARCH.DATA_TYPES.EXPENSE,
    icon: 'CreditCardHourglass',
    searchQuery: buildQueryStringFromFilterFormValues({
    type: CONST.SEARCH.DATA_TYPES.EXPENSE,
    feed: defaultFeedID ? [defaultFeedID] : [''],
    groupBy: CONST.SEARCH.GROUP_BY.CARD,
    status: [CONST.SEARCH.STATUS.EXPENSE.UNREPORTED, CONST.SEARCH.STATUS.EXPENSE.DRAFTS, CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING],
    }),
    get searchQueryJSON() {

    That argument is defaultCardFeed?.id, and defaultCardFeed is resolved one level up as defaultCardFeed ?? defaultExpensifyCard:

    defaultCardFeed: defaultCardFeed ?? defaultExpensifyCard,

    The two operands of that ?? are not peers, and that is the bug:

    • defaultCardFeed comes from getDefaultCardFeed, whose candidate pool is cardFeedsByPolicy — built by getCardFeedsForDisplayPerPolicy, which iterates getOriginalCompanyFeeds only. Expensify Card feeds are never in that pool; it is company card feeds exclusively.
    • getDefaultCardFeed prioritizes the active workspace, but when the active workspace has no company feed it does not stop — it falls through to the first other eligible workspace that has one, and finally to any commercial feed on the account:

    function getDefaultCardFeed(
    eligiblePoliciesIDsArray: string[] | undefined,
    activePolicyID: string | undefined,
    cardFeedsByPolicy: Record<string, CardFeedForDisplay[]>,
    localeCompare: (a: string, b: string) => number,
    ): CardFeedForDisplay | undefined {
    const eligiblePoliciesIDs = new Set(eligiblePoliciesIDsArray);
    // Prioritize the active policy if eligible
    if (activePolicyID && eligiblePoliciesIDs.has(activePolicyID)) {
    const policyCardFeeds = cardFeedsByPolicy[activePolicyID];
    if (policyCardFeeds?.length) {
    return [...policyCardFeeds].sort((a, b) => localeCompare(a.name, b.name)).at(0);
    }
    }
    // If the active policy doesn't have card feeds, use the first eligible policy that does
    for (const eligiblePolicyID of eligiblePoliciesIDs) {
    const policyCardFeeds = cardFeedsByPolicy[eligiblePolicyID];
    if (policyCardFeeds?.length) {
    return [...policyCardFeeds].sort((a, b) => localeCompare(a.name, b.name)).at(0);
    }
    }
    // Commercial feeds don't have preferred policies, so we need to include these in the list
    const commercialFeeds = Object.values(cardFeedsByPolicy)
    .flat()
    .filter((feed) => !isCustomFeed(feed.name as CardFeedWithNumber));
    return commercialFeeds.sort((a, b) => localeCompare(a.name, b.name)).at(0);
    }

    So defaultCardFeed is truthy as soon as any eligible workspace anywhere on the account has a company card feed, even one belonging to a workspace the user is not currently in. Because ?? only evaluates its right side when the left is nullish, defaultExpensifyCard is consulted only in the case where the account has no company card feed at all.

    The result matches the report exactly: the tester's account has another workspace carrying a Regions Bank feed, so that foreign company feed wins the default, and the Expensify Card feed of the active workspace — the only card feed it actually has — can never be selected. The identical wiring also feeds the Statements tab, which resolves its feed from the same defaultFeedID.

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

    Make the active workspace's own feeds win over other workspaces' feeds, instead of letting the Expensify Card feed be a global last-resort fallback.

    The Expensify Card feed should be a peer candidate inside the "prioritize the active policy" step of getDefaultCardFeed, rather than being bolted on afterwards with ?? in useSearchTypeMenuSections. Concretely:

    1. Pass the Expensify Card feed (the value currently read via defaultExpensifyCardSelector) into the default-feed resolution alongside the company feeds, so the selection logic can see it.

    2. In the active-policy branch, include that Expensify Card feed in the active workspace's candidate list when it belongs to that workspace — the feed carries a fundID, and a workspace is matched by its policyAccountID equalling that fundID, which is the same fund-to-workspace linkage getCardFeedsForDisplayPerPolicy already relies on for orphan feeds. Sort the combined list the same way the branch sorts today and return the first entry, so behaviour is unchanged for a workspace that has company feeds only.

      One detail matters for the reported case: that branch is entered today only when the active workspace is in the eligible-policies list, and that list is built from areCompanyCardsEnabled — a company-card gate:

      const eligiblePoliciesSelector = (policies: OnyxCollection<Policy>): string[] => {
      return Object.values(policies ?? {}).reduce((policiesIDs, policy) => {
      if (isPaidGroupPolicy(policy) && policy?.areCompanyCardsEnabled && policy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
      policiesIDs.push(policy.id);
      }
      return policiesIDs;
      }, [] as string[]);
      };

      A workspace with Expensify Cards but no company cards enabled fails that gate, which is exactly the reported precondition, so the Expensify Card candidate has to be considered for the active workspace independently of it. The company feeds stay behind the gate exactly as today — it is only the Expensify Card feed, which that gate was never meant to govern, that is evaluated regardless.

    3. Leave the remaining fallbacks in their current order — other eligible workspaces, then commercial feeds — and keep the Expensify Card feed as the final fallback for accounts with no company feed anywhere, which preserves today's behaviour for those accounts.

    With this, the reported precondition (active workspace has Expensify Card and no company feed, another workspace has Regions Bank) resolves the default to the Expensify Card feed, so Card accruals opens with feed:Expensify Card. The Statements tab benefits from the same correction, since it reads the same default.

    Because the default is consumed as a plain defaultFeedID, the fix stays confined to how that ID is chosen and needs no change to the suggested-search declarations themselves.

    Resolving this inside useCardFeedsForDisplay rather than at the ?? in useSearchTypeMenuSections also removes an existing divergence between the two consumers of the default: SearchQueryProvider builds the suggested searches from a bare defaultCardFeed, with no Expensify Card fallback of its own, so today the two can disagree about which feed the tab is for. Having a single resolved default keeps the menu and the suggested searches in agreement.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/96342-default-card-feed-active-workspace?expand=1

    What alternative solutions did you explore? (Optional)

    I considered flipping the operands to defaultExpensifyCard ?? defaultCardFeed. That fixes this repro but overcorrects in the mirror case: a workspace whose only feed is a company feed would start defaulting to an Expensify Card feed owned by a different workspace. The problem is not which of the two wins globally — it is that workspace ownership is ignored entirely — so the precedence has to be decided per workspace, not by reordering a global ??.

    I also considered including Expensify Card feeds directly in getCardFeedsForDisplayPerPolicy so they enter cardFeedsByPolicy naturally. That is arguably the tidier long-term shape, but cardFeedsByPolicy is consumed well beyond this default-feed path — the feed filter lists and the suggested-search visibility checks read it too — so widening it risks behaviour changes far outside the reported bug. Scoping the change to the default-feed resolution keeps the blast radius on the tab that is actually wrong.

  13. 71 remaining items

  14. added
    Awaiting Payment
    on Aug 9, 2026
  15. melvin-bot commented on Aug 9, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  16. melvin-bot commented on Aug 9, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
  17. Krishna2323 commented on Aug 10, 2026

    @Krishna2323
    Contributor

    BugZero Checklist:

    Regression Test Proposal

    Precondition:

    • You are an admin on a paid group workspace ("Workspace A")
    • Workspace A has the Expensify Card feature enabled, with at least one card assigned.
    • Workspace A also has a company/bank card feed connected.

    Test:

    1. Open the app.
    2. Set Workspace A as your active workspace.
    3. Go to Spends.
    4. Click Card accruals.
    5. Make sure search query shows feed:Expensify Card (not the company/bank feed).

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-c24d-a477-af73-02f017634134
  18. mallenexpensify commented on Aug 12, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Eskalifer1 paid $250 via Upwork
    Contributor+: @Krishna2323 due $250 via NewDot

    @Eskalifer1 can you please accept the job below? Please reply here and tag me once you have.
    If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
    https://www.upwork.com/jobs/~022077825703650533825

  19. Eskalifer1 commented on Aug 12, 2026

    @Eskalifer1
    Contributor

    Hi @mallenexpensify, i have accepted, thank you!

  20. mallenexpensify commented on Aug 12, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 paid, summary updated above. Thx.

  21. laurenreidexpensify commented on Aug 26, 2026

    @laurenreidexpensify
    Contributor

    $250 approved for @Krishna2323 New Expensify

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions