Skip to content

Expensify Card - Card is not marked as selected in Card list after spend rule is created #91899

Closed

Description

@applause-bot

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.84-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #89205
Email or phone of affected tester (no customers): applausetester+ssndjois2jd1@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Log in with Expensifail account.
  • Set up workspace with bank account and set up Expensify Card.
  • Enable Rules.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Expensify Card.
  3. Click Issue card.
  4. Proceed to Step 4 of Issue card flow.
  5. Enable Add spend rule.
  6. Click Create new.
  7. Enter the new rule info.
  8. Continue issuing card.
  9. After issuing card, go to Rules settings.
  10. Open the created spend rule.
  11. Click Choose cards.

Expected Result:

The card will be marked as selected in Card list after spend rule is created.

Actual Result:

The card is not marked as selected in Card list after spend rule is created.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7164576_1779908647889.13.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7164576

Issue OwnerCurrent Issue Owner: @JS00001

Activity

  1. applause-bot commented on May 27, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/957d930ec3f870dd4c936f1b4af57884d77db3378bc0eb8b1460a1632fb8321f

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 27, 2026
  3. melvin-bot commented on May 27, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #89205

  4. melvin-bot commented on May 27, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on May 27, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. MelvinBot commented on May 27, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    When issuing a new card with a "Create new" spend rule, the frontend calls buildSpendRuleAST(spendRuleValue) at Card.ts:1489. However, spendRuleValue comes from IssueNewCardData.spendRuleValue which has no cardIDs field — the card doesn't exist yet at this point.

    Inside buildSpendRuleAST, cardIDs defaults to [], and since the array is empty, the card_id filter node is omitted entirely from the AST`. The optimistic Onyx data for the rule is stored without any card association.

    Later, when viewing the spend rule from Rules settings, SpendRulePageBase calls getSpendRuleFormValuesFromCardRule() which parses the rule's AST and extracts cardIDs: []. SpendRuleCardPage reads this empty array, so no cards appear selected.

    The backend is expected to associate the newly created card with the rule and return the updated rule AST, but the frontend optimistic data never includes the card ID — and if the backend response doesn't properly update PRIVATE_EXPENSIFY_CARD_SETTINGS with the card ID in the rule's filter, the association remains missing.

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

    In issueExpensifyCard in Card.ts, when creating a new spend rule during card issuance:

    1. Generate the optimistic card ID first (it's already generated as optimisticCardID earlier in the function).
    2. Include this optimisticCardID in spendRuleValue.cardIDs before calling buildSpendRuleAST, so the optimistic rule AST contains the card_id filter node pointing to the new card.
    3. This ensures the optimistic Onyx data for the rule includes the card association immediately, so the card appears selected when viewing the spend rule from Rules settings before the backend response arrives.

    The same approach should be verified for the "copy existing" rule flow — when cardRuleID of an existing rule is sent, the frontend should optimistically add the new card ID to that existing rule's cardIDs filter as well.

    What alternative solutions did you explore?

    An alternative would be to add a success callback after card creation that refetches PRIVATE_EXPENSIFY_CARD_SETTINGS, but this adds latency and doesn't solve the optimistic UI gap. Including the card ID in the optimistic rule AST is more consistent with Expensify's offline-first architecture.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. luacmartins commented on May 27, 2026

    @luacmartins
    Contributor

    Feature is behind a beta. NAB

  8. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on May 27, 2026
  9. JS00001 commented on Jun 1, 2026

    @JS00001
    Contributor

    PR open, was waiting on web-e

  10. JS00001 commented on Jun 4, 2026

    @JS00001
    Contributor

    This is fixed

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.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions