You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spend rules - Card number appears in Spend rule after deactivating card #87450
Version Number: 9.3.55-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:#86684 Email or phone of affected tester (no customers):applausetester+khcategory20@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.2 / Chrome App Component: Workspace Settings
Action Performed:
Precondition:
Workspace is set up with Expensify Card feature.
Rules are enabled.
Workspace has at least one virtual card.
Go to staging.new.expensify.com
Go to workspace settings > Rules.
Click Add spend rule.
Add a card and add a spend rule, then save it.
Go to workspace settings > Expensify Card.
Deactivate the card used in Step 4.
Go to Go to workspace settings > Rules.
Scroll down to the created spend rule.
Expected Result:
Card number will not appear in Spend rule after deactivating card.
Actual Result:
Card number appears in Spend rule after deactivating card.
👋 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:
Identify the pull request that introduced this issue and revert it.
Root Cause: All three spend rule display components use filterInactiveCards as an Onyx selector when fetching the card list, which strips deactivated/closed cards from the lookup dictionary. The spend rule still stores those cardIDs, so the lookup returns undefined and the fallback renders the raw numeric card ID.
Recommended Fix: In SpendRulesSection.tsx (and SpendRulePageBase.tsx), use an unfiltered card list for resolving card display names. Keep filterInactiveCards only in SpendRuleCardPage.tsx (the card picker), where filtering is intentional.
Specifically:
SpendRulesSection.tsx:89 — remove the {selector: filterInactiveCards} option from the useOnyx call so deactivated cards remain in the lookup used at line 129.
SpendRulePageBase.tsx:57 — same change; the raw-ID fallback at line 93 will no longer trigger for deactivated cards.
SpendRuleCardPage.tsx:80 — keepfilterInactiveCards here, since users should not be able to add deactivated cards to new rules.
Investigation details
Data flow:
Spend rules store card references as cardIDs in the rule's filter AST on the backend (Card.ts:1652-1668).
When a card is deactivated, the backend does not remove its cardID from existing spend rules.
filterInactiveCards (CardUtils.ts:987-1003) removes cards with state CLOSED or STATE_DEACTIVATED.
SpendRulesSection.tsx:128-136 iterates over the rule's cardIDs, looks each up in the filtered cardsList, gets undefined for deactivated cards, and falls back to displaying the raw ID string.
Raw ID displayed: SpendRulesSection.tsx:131 — return cardID;
Alternative considered: Having the backend remove card references from spend rules on deactivation. This would be a more complete fix but is higher-risk for a deploy blocker. The frontend fix is safe and minimal.
Next Steps: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
Classification: Frontend bug
Causing PR: #86684 - Add spend rule base page by @luacmartins (High confidence)
Related Issues: #86521
Recommendation: REVERT
PR #86684 introduced the spend rules feature and contains the bug where a deactivated card still appears in the spend rule summary. The fix requires changes to the App, and the issue is staging-only (new feature, not in production), making a clean revert the safest option.
Assigned: @luacmartins (PR author), @suneox@JS00001 (approving reviewers)
Labels: Keeping DeployBlockerCash (frontend App bug). DeployBlocker is also on the issue but this is a frontend fix.
Evidence:
The melvin-bot already identified PR Add spend rule base page #86684 as the responsible PR (merged 2026-04-08, shortly before this report was filed on 2026-04-09).
PR Add spend rule base page #86684 introduced the entire SpendRulesSection spend rule display logic, the exact feature being tested in the reproduction steps.
The issue is staging-only (new feature, does not exist in prod), consistent with this PR being in the current staging deploy and not yet in production.
The card lookup uses cardsList filtered via filterInactiveCards in src/libs/CardUtils.ts.
Root Cause:
In SpendRulesSection.tsx (added by PR #86684), cardSummary is built by iterating over formValues.cardIDs stored in expensifyCardSettings.cardRules. When a card is deactivated, the card ID is not removed from existing rules. The deactivate action (src/libs/actions/Card.ts) optimistically nulls the card from cardsList, and filterInactiveCards also filters out STATE_DEACTIVATED (state=5) and CLOSED (state=6) cards. However, there is no code path in this PR to gracefully handle display of a card that was deactivated after a spend rule was created. The current fallback either returns the raw cardID string (if the card is fully removed from cardsList), or getCardDescriptionForSearchTable still shows the card number if the server returns a state that is not caught by the filter.
As I mentioned, when deactivating a card, we don’t have any documentation describing this behavior. So I think we should handle it as a separate issue. In this case, we would need a backend update api Card_Deactivate to clean up the unused PRIVATE_EXPENSIFY_CARD_SETTINGS
Activity
melvin-bot commentedon Apr 9, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #86684
melvin-bot commentedon Apr 9, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Apr 9, 2026
👋 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:
MelvinBot commentedon Apr 9, 2026
Issue Analysis
Root Cause: All three spend rule display components use
filterInactiveCardsas an Onyx selector when fetching the card list, which strips deactivated/closed cards from the lookup dictionary. The spend rule still stores thosecardIDs, so the lookup returnsundefinedand the fallback renders the raw numeric card ID.Recommended Fix: In
SpendRulesSection.tsx(andSpendRulePageBase.tsx), use an unfiltered card list for resolving card display names. KeepfilterInactiveCardsonly inSpendRuleCardPage.tsx(the card picker), where filtering is intentional.Specifically:
SpendRulesSection.tsx:89— remove the{selector: filterInactiveCards}option from theuseOnyxcall so deactivated cards remain in the lookup used at line 129.SpendRulePageBase.tsx:57— same change; the raw-ID fallback at line 93 will no longer trigger for deactivated cards.SpendRuleCardPage.tsx:80— keepfilterInactiveCardshere, since users should not be able to add deactivated cards to new rules.Investigation details
Data flow:
cardIDs in the rule's filter AST on the backend (Card.ts:1652-1668).cardIDfrom existing spend rules.filterInactiveCards(CardUtils.ts:987-1003) removes cards with stateCLOSEDorSTATE_DEACTIVATED.SpendRulesSection.tsx:128-136iterates over the rule'scardIDs, looks each up in the filteredcardsList, getsundefinedfor deactivated cards, and falls back to displaying the raw ID string.Evidence chain:
SpendRulesSection.tsx:89—useOnyx(..., {selector: filterInactiveCards})SpendRulesSection.tsx:129—const card = cardsList?.[cardID];returnsundefinedSpendRulesSection.tsx:131—return cardID;Alternative considered: Having the backend remove card references from spend rules on deactivation. This would be a more complete fix but is higher-risk for a deploy blocker. The frontend fix is safe and minimal.
Next Steps: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.OSBotify commentedon Apr 9, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #86684 - Add spend rule base page by @luacmartins (High confidence)
Related Issues: #86521
Recommendation: REVERT
PR #86684 introduced the spend rules feature and contains the bug where a deactivated card still appears in the spend rule summary. The fix requires changes to the App, and the issue is staging-only (new feature, not in production), making a clean revert the safest option.
Assigned: @luacmartins (PR author), @suneox @JS00001 (approving reviewers)
Labels: Keeping DeployBlockerCash (frontend App bug). DeployBlocker is also on the issue but this is a frontend fix.
Evidence:
Verification:
Root Cause:
In SpendRulesSection.tsx (added by PR #86684), cardSummary is built by iterating over formValues.cardIDs stored in expensifyCardSettings.cardRules. When a card is deactivated, the card ID is not removed from existing rules. The deactivate action (src/libs/actions/Card.ts) optimistically nulls the card from cardsList, and filterInactiveCards also filters out STATE_DEACTIVATED (state=5) and CLOSED (state=6) cards. However, there is no code path in this PR to gracefully handle display of a card that was deactivated after a spend rule was created. The current fallback either returns the raw cardID string (if the card is fully removed from cardsList), or getCardDescriptionForSearchTable still shows the card number if the server returns a state that is not caught by the filter.
luacmartins commentedon Apr 9, 2026
This feature is behind an environment beta. No need to revert.
suneox commentedon Apr 9, 2026
As I mentioned, when deactivating a card, we don’t have any documentation describing this behavior. So I think we should handle it as a separate issue. In this case, we would need a backend update api Card_Deactivate to clean up the unused PRIVATE_EXPENSIFY_CARD_SETTINGS
JS00001 commentedon Apr 13, 2026
Closing this in favor of #87669