Skip to content

[$250] NewDot Capital One card assignment flow does not surface new card available to assign #91977

Closed

Description

@m-natarajan

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: 9.3.83-3
Reproducible in staging?: Needs reproduction (Unable to reproduce)
Reproducible in production?: Needs reproduction
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: @Tmjarnesk1
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Customer opens the Capital One company card connection in New Expensify.
  2. Customer selects Assign new cards.
  3. Customer logs into Capital One using the master Capital One credentials.
  4. Customer attempts to assign a new employee card.
  5. The new card does not appear as available to assign.

Expected Result:

The new Capital One card should appear in the available card list so it can be assigned to the employee.

Actual Result:

The card does not appear in New Expensify as available to assign, even though the card is visible in Capital One and has posted activity.

Additional context:

  • Card Provider: Capital One
  • Card is new and has never been assigned in Expensify.
  • Customer confirmed card is visible in Capital One.
  • Customer confirmed the card has a posted transaction.
  • Customer confirmed they are using the master Capital One credentials.
  • Customer confirmed the Capital One username/credentials have not changed since the original connection was created.
  • Existing Capital One connection appears to work for other cards; only this new card is missing.
  • Customer does not want to rebuild/disconnect the connection because unassigning cards may remove unapproved transactions or Draft reports, and reassignment could risk duplicate imports if the Transaction Start Date is not set carefully.

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit

Activity

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

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The App displays available Capital One cards based entirely on the accountList array provided by the backend. For direct/OAuth feeds like Capital One (oauth.capitalone.com), the card assignment flow in CardSelectionStep.tsx reads accountList from Onyx (populated by the OpenPolicyCompanyCardsPage / OpenPolicyCompanyCardsFeed backend API responses) and filters out already-assigned cards via getFilteredCardList. No other client-side filtering is applied.

    If the new Capital One card is not in the backend-returned accountList, it will never appear in the UI. The accountList is only refreshed when the user re-authenticates via the OAuth flow — navigating to Company Cards → Settings → "Assign new cards" triggers startCardFeedRefresh, which opens the bank's OAuth popup. The backend then refreshes the connection and updates accountList.

    Critically, simply navigating to the card assignment screen does not trigger a fresh fetch from Capital One — it only reads the cached backend data. This means:

    1. If the customer never used "Assign new cards" in feed settings: The accountList is stale and won't include the new card.
    2. If the customer did use "Assign new cards" and re-authenticated: The issue is backend-side — Capital One's API may not be returning the new card, or the backend may not be updating accountList after re-authentication.

    This appears to be a backend/internal issue. A separate internal investigation is needed to confirm whether accountList is being properly refreshed after OAuth re-authentication and whether Capital One's API returns the new card.

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

    The fix depends on which layer is at fault:

    1. If the customer hasn't used the refresh flow: This is working as designed — the customer should use Company Cards → Settings → "Assign new cards" to trigger a re-authentication with Capital One, which refreshes the card list.

    2. If the refresh flow was used but the card still doesn't appear: The backend needs to be investigated. The OpenPolicyCompanyCardsPage and OpenPolicyCompanyCardsFeed API responses should be checked to see if the new card is present in accountList after re-authentication. The fix would be on the backend to ensure newly added bank cards are included in the accountList returned after an OAuth refresh.

    3. Potential App-side improvement: Unlike Plaid feeds which automatically refresh the card list when starting the assign flow (via importPlaidAccounts), OAuth feeds like Capital One have no such automatic refresh. Adding an equivalent mechanism for OAuth feeds could prevent this class of issue.

    Investigation details

    Data flow for Capital One card assignment:

    1. User navigates to Workspace → Company Cards page
    2. openPolicyCompanyCardsPage() and openPolicyCompanyCardsFeed() send READ API calls to the backend
    3. Backend returns feed metadata including accountList (array of card names) via Onyx updates
    4. User clicks "Assign card" → CardSelectionStep renders
    5. getFilteredCardList() takes accountList, removes already-assigned cards, returns available cards
    6. If a card is absent from accountList, it cannot appear in the UI

    Key code references:

    Related issue: #91199 — Capital One credential errors when assigning cards to a second workspace (different issue but same feed type)


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement this 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 May 28, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 28, 2026
  5. yusufdeveloper2903 commented on May 28, 2026

    @yusufdeveloper2903
    Contributor

    Proposal

    What is the root cause of that problem?

    When a new Capital One card is added after the initial connection is established, the card assignment flow relies on a cached or previously fetched list of available cards. The fetch/refresh of available cards during the assignment flow does not trigger a re-sync from the Capital One connection, so newly issued cards that exist in Capital One but were never imported into Expensify are absent from the assignable card list.

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

    I'd suggest adding a "Refresh available cards" trigger when the user enters the card assignment step, so the list is re-fetched from the server rather than relying solely on cached Onyx data. The relevant action likely lives around src/libs/actions/Card.ts (or a similar cards action file).

    // In the card assignment page (e.g. src/pages/WorkspaceCardAssignPage or equivalent)
    + useEffect(() => {
    +     // Re-fetch available cards from the connection so newly issued cards appear
    +     CardActions.refreshCompanyCards(policyID);
    + }, [policyID]);

    Additionally, I'd suggest surfacing a manual "Refresh" button or an informational note on the assign card screen so users can trigger a re-sync without rebuilding the entire connection, avoiding the risk of duplicate imports or lost transactions.

    What alternative solutions did you explore?

    One alternative is to increase the polling frequency of the card list sync job on the backend so new cards are picked up automatically within a short window — but that doesn't help users who are actively sitting on the assignment screen and need the card to appear immediately. The UI-side refresh on mount is a simpler, lower-risk fix that preserves the existing connection state.

  6. KJ21-ENG commented on May 28, 2026

    @KJ21-ENG
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-05-28 14:41:07 UTC.

    Proposal

    What is the root cause of that problem?

    Capital One is an OAuth direct feed. The "Assign new cards" setting starts a refresh flow by seeding ASSIGN_CARD.currentStep and opening RefreshCardFeedConnectionPage, but that page reuses the normal assign-card BankConnection behavior.

    That existing-feed behavior is built for expired/broken assignment recovery. If the feed is not expired, it advances to the assignee step instead of forcing a Capital One refresh. If the feed does re-authenticate, RefreshCardFeedConnectionPage closes when expiration/isRefreshing changes, but it does not reload the accountList/WORKSPACE_CARDS_LIST data used by the table and card picker. The picker then runs getFilteredCardList() against stale data, so the newly issued Capital One card is missing.

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

    Add explicit refresh/discovery handling for direct-feed "Assign new cards" instead of reusing the regular assign-card recovery path.

    For OAuth feeds such as Capital One, the refresh path should not treat "feed is not expired" as completion. It should either force the selected bank OAuth refresh or call the existing OpenAssignFeedCardPage/company-card feed read command intended to refresh assignable feed cards. After the refresh completes, reload the selected policy/feed card data with the existing domainAccountID, policyID, and feed params before closing or rendering the picker, so accountList and WORKSPACE_CARDS_LIST are fresh.

    Keep the current fast path for clicking an already visible unassigned card row, and keep the existing expired/broken connection recovery behavior for normal assignment. Plaid can continue using ImportPlaidAccounts, but it should trigger the same post-refresh data reload before the flow closes.

    Add tests for:

    • a non-expired Capital One/OAuth feed using "Assign new cards" and still triggering card discovery instead of jumping to assignee/loading state,
    • refreshed accountList data making a new unassigned Capital One card appear in CardSelectionStep,
    • clicking an already visible unassigned row continuing through the existing assignment path without an unnecessary refresh.

    What alternative solutions did you explore? (Optional)

    Changing getFilteredCardList() alone would not solve this because it can only display cards already present in accountList or cardList. Disconnecting and rebuilding the feed is also not acceptable because it can unassign cards and risks duplicate imports.

  7. melvin-bot commented on May 28, 2026

    @melvin-bot

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

  8. changed the title [-]NewDot Capital One card assignment flow does not surface new card available to assign[/-] [+][$250] NewDot Capital One card assignment flow does not surface new card available to assign[/+] on May 28, 2026
  9. melvin-bot commented on May 28, 2026

    @melvin-bot
  10. Abdulloh0109 commented on May 28, 2026

    @Abdulloh0109
    Contributor

    Proposal

    What is the root cause of that problem?

    I started from the exact UI element the customer describes — the assignable-card list shown in the "Assign new cards" picker for an OAuth direct feed (Capital One, oauth.capitalone.com per CONST/index.ts#L4233). That list is built in CardSelectionStep.tsx#L56 by feeding cardFeeds?.[feed]?.accountList into getFilteredCardList. For direct feeds (OAuth or Plaid, detected by isDirectFeed), accountList is the only source of truth — any card name missing from it cannot appear, regardless of what Capital One actually shows on the bank side.

    I then traced the write path that keeps accountList current. accountList only changes when the backend pushes an Onyx update in response to a card-feed READ. Two READs touch it: OPEN_POLICY_COMPANY_CARDS_FEED (called on the company-cards page load via openPolicyCompanyCardsFeed) and the Plaid-specific importPlaidAccounts, which useAssignCard fires for Plaid feeds at useAssignCard.ts#L163-L167 immediately before the picker is shown.

    Direct OAuth feeds like Capital One never get an equivalent refresh between OAuth re-authentication and the picker render. Clicking "Assign new cards" routes through startCardFeedRefresh → BankConnection/index.tsx#L122-L145, which only opens the bank's OAuth popup; the OAuth round-trip eventually advances cardFeeds?.[feed]?.expiration (which is what RefreshCardFeedConnectionPage.tsx#L51-L58 waits for before closing the RHP) but nothing in the assign-card flow then asks the server to publish the new accountList for that specific feed. The picker re-renders against whatever accountList happened to be cached the last time the company-cards page was loaded — so a newly issued Capital One card whose name was not yet on that cached list is invisible.

    The backend has the right primitive for this gap already: API/types.ts#L1330 defines READ_COMMANDS.OPEN_ASSIGN_FEED_CARD_PAGE (typed at API/types.ts#L1443 with the same OpenPolicyCompanyCardsFeedParams shape), but no caller exists anywhere under src/. The write-side counterpart that the OAuth picker needs is wired up but never invoked.

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

    The fix is at the data layer feeding the picker, not the OAuth flow itself. Mirror the Plaid pre-render refresh for direct OAuth feeds, using the already-defined OPEN_ASSIGN_FEED_CARD_PAGE command.

    1. Add an action wrapper in src/libs/actions/CompanyCards.ts — e.g. openAssignFeedCardPage(domainAccountID, policyID, feed, translate) that calls API.read(READ_COMMANDS.OPEN_ASSIGN_FEED_CARD_PAGE, parameters, ...). Reuse the same cardFeedsStatus.[feed].isLoading/FEED_LOAD_ERROR optimistic/success/failure pattern as the existing openPolicyCompanyCardsFeed, so the skeleton/error UI the picker already supports continues to work.

    2. Invoke it from useInitialAssignCardStep next to the Plaid branch — alongside useAssignCard.ts#L163-L167, add a sibling branch guarded by isDirectFeed(selectedFeed) && !plaidAccessToken && !isFeedExpired, fired once per mount via a useRef flag the same way hasImportedPlaidAccounts is. This ensures every entry into the OAuth picker triggers exactly one fresh accountList pull, matching the Plaid behavior contributors already rely on.

    3. Also fire it after OAuth re-authentication in RefreshCardFeedConnectionPage — the existing effect at RefreshCardFeedConnectionPage.tsx#L51-L58 detects OAuth completion via feedExpiration change and immediately closes the RHP. Before closing, dispatch openAssignFeedCardPage so the very next time the user opens the picker, accountList reflects what Capital One returned to the backend a moment ago rather than what was cached before the OAuth round-trip.

    4. Gate the picker empty state on the new loading flag — in CardSelectionStep.tsx#L56, read cardFeeds?.[feed]?.status?.isLoading (or the existing cardFeedsStatus[feed].isLoading flag set by the optimistic data above) and render the existing loading skeleton while filteredCardList is empty AND the refresh request is in flight, so the customer doesn't see a "no cards" state momentarily flash before the new card lands.

    No change to the OAuth bank-connection flow itself, no change to the Plaid branch, and no schema change — the backend command type and Onyx loading-status fields already exist.

    What alternative solutions did you explore? (Optional)

    1. The "useEffect on CardSelectionStep mount that calls a generic refreshCompanyCards(policyID)" approach — this refreshes every feed on the workspace each time the picker mounts, even feeds the user isn't touching, and goes through the same OPEN_POLICY_COMPANY_CARDS_PAGE path that already fired when the workspace page was opened. It doesn't reuse the backend's per-feed OPEN_ASSIGN_FEED_CARD_PAGE primitive that was clearly added for this exact surface, and there's no precise loading state to gate the empty-list UI against, so the picker can still flash "no cards" before the bulk refresh lands. The narrower per-feed action is both cheaper and aligned with the existing Plaid pattern at useAssignCard.ts#L163-L167.

    2. The "always force OAuth re-authentication when no cardID is given" approach — would make useAssignCard send the user back through the bank-login popup every time they enter "Assign new cards", regardless of feedExpiration. The existing fast-path in BankConnection/index.tsx#L122-L145 deliberately skips OAuth when !isFeedExpired, because re-entering master credentials per assignment is a real UX regression (and in many orgs the assigner doesn't hold those credentials). It also doesn't address the actual gap: accountList is never re-fetched on the client between OAuth completion and the next picker render — even if the OAuth round-trip is forced, the symptom recurs as soon as a different admin opens the picker later without re-authenticating.

  11. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    ⚠️ @Abdulloh0109 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  12. David-2002065 commented on May 28, 2026

    @David-2002065
    Contributor

    Proposal

    What is the root cause of that problem?

    The customer in this bug did use the "Assign new cards" → OAuth re-authentication flow (per the repro, steps 2–3), yet the new card still doesn't surface. So the proposals that focus on adding an upfront refresh before the picker don't address what actually happened here — the refresh did happen, the data just never re-arrived.

    Looking at the post-OAuth handoff in RefreshCardFeedConnectionPage.tsx#L54-L60:

    // OAuth feeds: expiration updates after bank re-authentication completes
    useEffect(() => {
        if (prevFeedExpiration === undefined || prevFeedExpiration === feedExpiration || !isRefreshing) {
            return;
        }
        Navigation.closeRHPFlow();
    }, [prevFeedExpiration, feedExpiration, isRefreshing]);

    The App treats "expiration changed" as a synonym for "accountList is now fresh and complete" — it closes the RHP the moment the new expiration date lands and never explicitly re-reads the feed. But the two Onyx fields are updated by separate backend code paths: the OAuth callback bumps the expiration immediately when re-auth succeeds, while accountList is repopulated by a downstream account-discovery job that fans out to Capital One's API. If that job hasn't completed (or hasn't yet propagated back to the user's Onyx) by the time feedExpiration updates, the RHP closes and CardSelectionStep reads a stale accountList that's missing the newly-issued card.

    Compare to the Plaid path on #L46-L52 where isRefreshing is cleared by the importPlaidAccounts successData itself — so closing the flow is gated on the data arriving, not on a sibling field. The OAuth branch has no equivalent data-arrival signal; it gates only on expiration, which is the wrong sentinel.

    The "no auto-refresh on assign entry" path that KJ21-ENG and MelvinBot focus on is a real gap too, but it's a different gap: it covers users who never re-authed. This customer did re-auth, and we still let them out of the refresh page before accountList was actually fresh.

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

    Don't trust expiration as a proxy for "accountList is fresh." After the OAuth callback flips the expiration, explicitly re-read the feed and wait for that read to finish before closing the RHP:

         // OAuth feeds: expiration updates after bank re-authentication completes
         useEffect(() => {
             if (prevFeedExpiration === undefined || prevFeedExpiration === feedExpiration || !isRefreshing) {
                 return;
             }
    -        Navigation.closeRHPFlow();
    +        // expiration just changed → OAuth re-auth completed, but accountList may not yet reflect
    +        // newly-discovered cards. Force a re-read of the feed and gate the close on that response
    +        // so the picker never opens against stale data.
    +        const domainAccountID = cardFeeds?.[feed]?.domainAccountID ?? CONST.DEFAULT_NUMBER_ID;
    +        openPolicyCompanyCardsFeed(domainAccountID, policyID, feed, translate)?.then(() => {
    +            Navigation.closeRHPFlow();
    +        });
         }, [prevFeedExpiration, feedExpiration, isRefreshing]);

    (openPolicyCompanyCardsFeed already lives in CompanyCards.ts#L959 — it needs to return its API.read promise so the caller can await it. That's a one-line return addition.)

    Secondary improvement: surface a manual "Refresh card list" affordance in CardSelectionStep when filteredCardList.length === 0 (or always, as a small icon button next to the search input), wired to the same openPolicyCompanyCardsFeed action. That gives the customer a self-serve recovery path without requiring them to disconnect/rebuild the feed (which they explicitly want to avoid per the bug's "Additional context").

    Tests to add in tests/unit/CompanyCardsTest.ts: simulate an OAuth refresh where feedExpiration updates before accountList does (stale → fresh on a second Onyx tick); assert the RHP doesn't close until the explicit feed re-read resolves, and that the picker renders the new card name.

    What alternative solutions did you explore? (Optional)

    • Add a fixed delay between the expiration update and Navigation.closeRHPFlow() to give accountList time to land. Rejected — race-condition band-aids don't scale, and on slow backends the delay either isn't long enough (bug persists) or hurts UX for everyone.
    • Wire up READ_COMMANDS.OPEN_ASSIGN_FEED_CARD_PAGE before the picker (KJ21-ENG's angle). Good defensive measure for users who haven't re-authed, but doesn't help this specific bug — the customer did re-auth and the picker already opened against the stale feed; they'd hit the same problem on the second attempt unless the feed read this time happens to land in the right order. The post-OAuth fix above closes that ordering hole at its source.
    • Backend-only fix (MelvinBot's primary suggestion). It's plausibly also needed — if Capital One's accountList truly never includes the new card, no amount of client refresh fixes it. But the App still has a correctness bug today (closing the refresh flow on the wrong signal), and a frontend fix is reproducible/testable without backend access.
  13. 7 remaining items

  14. melvin-bot commented on Jun 2, 2026

    @melvin-bot

    @DylanDylann Eep! 4 days overdue now. Issues have feelings too...

  15. melvin-bot commented on Jun 4, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  16. melvin-bot commented on Jun 4, 2026

    @melvin-bot

    @DylanDylann Still overdue 6 days?! Let's take care of this!

  17. DylanDylann commented on Jun 5, 2026

    @DylanDylann
    Contributor
  18. melvin-bot commented on Jun 8, 2026

    @melvin-bot

    @DylanDylann Whoops! This issue is 2 days overdue. Let's get this updated quick!

  19. melvin-bot commented on Jun 10, 2026

    @melvin-bot

    @DylanDylann Eep! 4 days overdue now. Issues have feelings too...

  20. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  21. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    @DylanDylann this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

  22. DylanDylann commented on Jun 12, 2026

    @DylanDylann
    Contributor

    @joekaufmanexpensify Based on your last message in the Slack thread, should we close this issue or is there anything else we need to do here?

  23. joekaufmanexpensify commented on Jun 12, 2026

    @joekaufmanexpensify
    Contributor

    Yeah, we can close it. The issue is resolved for the customer, seems like may have been an issue on the bank side 👍

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions