Skip to content

[Due for payment 2026-04-28] [Card Rules] - Hide deactivated cards from rule summary and selection lists #87669

Closed

Description

@luacmartins

Problem

When a virtual card used by a spend rule is deactivated, the spend rules UI can still surface that deactivated card in the rule summary and/or selection lists.

Proposed behavior

We should update the spend rules experience so deactivated cards are no longer surfaced in these places.

Possible approaches:

  • Hide the entire rule when it only contains deactivated cards.
  • Hide deactivated cards from the rule summary and selection lists.

Context

Follow-up from #87180 (comment) and #87180 (comment).

Related but separate from #87450, which is tracking backend cleanup of unused PRIVATE_EXPENSIFY_CARD_SETTINGS when a card is deactivated.

Issue OwnerCurrent Issue Owner: @suneox

Activity

  1. self-assigned this
    on Apr 10, 2026
  2. changed the title [-]Spend rules - Hide deactivated cards from rule summary and selection lists[/-] [+][Card Rules] - Hide deactivated cards from rule summary and selection lists[/+] on Apr 10, 2026
  3. luacmartins commented on Apr 10, 2026

    @luacmartins
    ContributorAuthor

    @MelvinBot work on a proposal for this

  4. MelvinBot commented on Apr 10, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The rule summary in SpendRulesSection.tsx and the card menu in SpendRulePageBase.tsx build card display text by iterating over formValues.cardIDs from the rule's filter AST. Although cardsList is fetched with the filterInactiveCards selector (which excludes deactivated/closed cards), when a card ID is missing from cardsList, the code falls back to displaying the raw numeric card ID instead of hiding the entry.

    Specifically in SpendRulesSection.tsx:127-139:

    const card = cardsList?.[cardID];
    if (!card || !isCard(card)) {
        return cardID;  // ← shows raw ID for deactivated cards
    }
    

    The same pattern exists in SpendRulePageBase.tsx:109-122.

    The card selection list (SpendRuleCardPage.tsx) is already correct — it uses the filterInactiveCards selector and only shows active cards.

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

    Filter out deactivated card IDs (those not present in the active cardsList) before building the display summaries:

    1. SpendRulesSection.tsx — In the createdRules mapping (~line 127), filter formValues.cardIDs to only include IDs present in cardsList before passing them to getTruncatedSpendRuleSummary. Also filter formValues.cardIDs the same way before passing to getSelectedCardsSharedCurrency. If a rule ends up with zero active cards after filtering, skip rendering it (return undefined so it's filtered out).

    2. SpendRulePageBase.tsx — In getCardsMenuTitle (~line 109), apply the same filter: skip card IDs not found in cardsList rather than falling back to displaying the raw ID.

    This approach keeps the rules data intact on the backend (no data loss) while simply hiding deactivated cards from the UI, consistent with how the card selection list already works.

    What alternative solutions did you explore? (Optional)

    • Backend cleanup on card deactivation — Removing card IDs from rules when a card is deactivated. This is being tracked separately in Spend rules - Card number appears in Spend rule after deactivating card #87450 and would be complementary, but a frontend filter is still needed as a defensive measure.
    • Showing a "deactivated" indicator instead of hiding — This adds UI complexity without clear user benefit, since deactivated cards can't be used.

    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.

  5. luacmartins commented on Apr 10, 2026

    @luacmartins
    ContributorAuthor

    @MelvinBot implement this

  6. MelvinBot commented on Apr 10, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #87679
    Please mark it as "Ready for review" when it is ready for review.

  7. changed the title [-][Card Rules] - Hide deactivated cards from rule summary and selection lists[/-] [+][Due for payment 2026-04-28] [Card Rules] - Hide deactivated cards from rule summary and selection lists[/+] on Apr 21, 2026
  8. melvin-bot commented on Apr 21, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  9. melvin-bot commented on Apr 21, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.60-22 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-04-28. 🎊

    For reference, here are some details about the assignees on this issue:

    • @suneox requires payment through NewDot Manual Requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions