App icon indicating copy to clipboard operation
App copied to clipboard

Expensify Card - Expensify Cards with a $0 limit do not appear in New Expensify

Open vincdargento opened this issue 2 months ago • 39 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: v9.4.77-2 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from TestRail: https://github.com/Expensify/Expensify/issues/642930 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team

Action Performed:

Preconditions:

  • logged in to expensifail account that being a domain admin, create a workspace and enabled the expensify card to that account
  • Assign an expensify card to any member

Steps:

  1. Navigate to OD, navigate to Settings -> Domain -> Workspace -> Expensify Card -> Card list
  2. Edit limit Expensify Cards with a $0
  3. Back to ND
  4. Click Workspaces > [workspace name] > Expensify Card

Expected Result:

The Expensify Cards with a $0 limit appear in New Expensify

Actual Result:

Expensify Cards with a $0 limit in Expensify Classic doesn't appear in ND

Workaround:

N/A

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [x] MacOS: Chrome / Safari

Screenshots/Videos

https://github.com/user-attachments/assets/0a520459-b635-436c-93e1-f0bf78bf7f53

Issue OwnerCurrent Issue Owner: @arosiclair

vincdargento avatar Sep 14 '26 15:09 vincdargento

Proposal

What is the root cause of that problem?

Setting a $0 limit in Expensify Classic moves the card to STATE_DEACTIVATED (5). New Expensify's workspace card list unconditionally drops every state-5 card, so the card disappears.

The filter is isActiveCard in src/libs/CardUtils.ts:1274-1279. The includeDeactivated flag only widens the STATE_SUSPENDED branch — the fall-through return excludes STATE_DEACTIVATED no matter what the flag says.

This is a regression of Expensify/App#82466, not a new bug. PR #86420 (merged 2026-05-12) fixed #82466 by keeping admin-zeroed deactivated cards. PR #90540 (merged 2026-05-19, seven days later) removed that carve-out to fix Expensify/App#90487, where editing such a card's limit returned a 403. Its test step 7 — "Verify that deactivated cards (STATE_DEACTIVATED) do NOT appear" — asserts the exact opposite of what this issue asks for.

Evidence chain

Where the card is dropped. The page reads cards through an Onyx selector at WorkspaceExpensifyCardPage.tsx:40 → filterInactiveCardsForWorkspace → filterAllInactiveCards(list, true, true) → isActiveCard(card, true). Anything this selector removes can never render.

Nothing filters on the limit value. I checked the whole list path — no !limit, limit > 0, or falsy check on unapprovedExpenseLimit. The $0 limit only matters because it triggers the backend state change. The limit is a display field only.

Why state 5 and not 7. Suspended (7) cards are kept unconditionally on this page today. If Classic set a $0 card to 7, it would still be visible. It isn't, so it is 5. The in-repo doc comment at CardUtils.ts:1281-1286 still describes the deleted #86420 behavior and confirms the backend "transitions to deactivated/suspended".

Why CI stays green. tests/unit/CardUtilsTest.ts:3860-3862 asserts result.adminZeroedDeactivated is undefined — a fixture that is literally this issue's scenario (Expensify bank, hasCustomUnapprovedExpenseLimit: true, unapprovedExpenseLimit: 0). The broken behavior is locked in by tests.

Alternatives I ruled out. The cardholder-membership filter at WorkspaceExpensifyCardListPage.tsx:110-113 also drops cards, but it is limit-agnostic and the card here is assigned to a member. A missing-from-payload backend cause is unlikely: #90487's QA confirmed the card did appear in New Expensify while the carve-out existed, so the API does return it. PR #95272 only extracted isActiveCard and preserved #90540's semantics — not the cause.

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

Restore #86420's narrow carve-out rather than reverting #90540 wholesale. In isActiveCard, keep a STATE_DEACTIVATED card when includeDeactivated is set and it is an Expensify Card with an admin-set $0 limit. The predicate already exists and is unused by this path: isCardWithCustomZeroLimit at CardUtils.ts:1713-1715. This satisfies this issue while keeping genuinely deactivated cards (the #90487 complaint) out of the list.

Also update the assertions at CardUtilsTest.ts:3803 and :3860, which currently enshrine the bug.

⚠️ One thing to settle before implementing. #90540's stated reason for the removal was that the server returns 403 on a limit update for a deactivated card. I could not verify that claim — it lives in Auth, which I can't read. If it still holds, simply showing the card re-opens #90487, because the limit row on DynamicWorkspaceExpensifyCardDetailsPage.tsx stays editable for deactivated cards. An internal engineer should confirm whether Auth still 403s UpdateExpensifyCardLimit for state 5. If it does, the fix needs a backend change too, or the card should surface with a reactivate affordance instead of a limit edit that is guaranteed to fail.

What alternative solutions did you explore? (Optional)

A straight revert of #90540 — rejected, because it also brings back non-zeroed deactivated cards and re-opens #90487. Gating the carve-out on isCardWithCustomZeroLimit is the narrower option that satisfies both issues.

Related issues

  • Expensify/App#82466 — the same bug, closed 2026-05-30. This issue is a regression of it.
  • Expensify/App#90487 — the deploy blocker whose fix (#90540) caused this regression. Any fix must not re-break it.

I did not attempt a live reproduction: the flow needs a Classic domain admin with an issued Expensify Card and a verified settlement account, which the test account doesn't have.


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


view run · no recording available

MelvinBot avatar Sep 14 '26 15:09 MelvinBot

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

melvin-bot[bot] avatar Sep 14 '26 15:09 melvin-bot[bot]

Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

melvin-bot[bot] avatar Sep 14 '26 15:09 melvin-bot[bot]

Proposal

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

Expensify Cards (physical or virtual) that have their Smart Limit set to $0 via Expensify Classic do not appear in the New Expensify workspace card management view.

What is the root cause of that problem?

This is a pure frontend logic flaw, not a backend limitation.

When an admin sets a card's limit to $0, the backend transitions the card state to STATE_DEACTIVATED (5). The WorkspaceExpensifyCardPage relies on the Onyx selector filterInactiveCardsForWorkspace to get the list of cards.

If we look at the JSDoc comment for filterAllInactiveCards in src/libs/CardUtils.ts, the original developer's intent is explicitly documented:

"When includeDeactivated is true (workspace card management views), admin-zeroed Expensify Cards are also kept - these are cards an admin set to a $0 limit, which the backend then transitions to deactivated/suspended. Admins still need to be able to find and manage them."

However, the implementation of isActiveCard() fails to honor this rule for deactivated states. It currently looks like this:

function isActiveCard(card: Card, includeDeactivated = false): boolean {
    if (card.state === CONST.EXPENSIFY_CARD.STATE.STATE_SUSPENDED) {
        return !!card.nameValuePairs?.frozen || includeDeactivated;
    }
    return card.state !== CONST.EXPENSIFY_CARD.STATE.CLOSED && card.state !== CONST.EXPENSIFY_CARD.STATE.STATE_DEACTIVATED;
}

Because of the unconditional check at the end (&& card.state !== CONST.EXPENSIFY_CARD.STATE.STATE_DEACTIVATED), a $0 limit card is always filtered out, even when the workspace table passes includeDeactivated = true.

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

We must fix isActiveCard in src/libs/CardUtils.ts so that it properly respects the includeDeactivated flag for STATE_DEACTIVATED, exactly as it already does for STATE_SUSPENDED.

Change isActiveCard (approx line 1275) to:

function isActiveCard(card: Card, includeDeactivated = false): boolean {
    if (
        card.state === CONST.EXPENSIFY_CARD.STATE.STATE_SUSPENDED || 
        card.state === CONST.EXPENSIFY_CARD.STATE.STATE_DEACTIVATED
    ) {
        return !!card.nameValuePairs?.frozen || includeDeactivated;
    }
    
    return card.state !== CONST.EXPENSIFY_CARD.STATE.CLOSED;
}

This single-line structural fix aligns the code with its documented business logic. The $0 limit cards (STATE_DEACTIVATED) will now correctly render in the Workspace Card list where includeDeactivated is true, while remaining hidden in standard user views where it is false.

Alternative solutions:

None. Modifying the backend to stop sending STATE_DEACTIVATED when a limit is $0 would break the integration and state machine used by Expensify Classic. This frontend filter fix is the exact intended mechanism.

Mister124x avatar Sep 14 '26 23:09 Mister124x

Verification Update

I verified this fix locally against the latest main branch:

  • Confirmed that cards with Smart Limit $0 in STATE_DEACTIVATED are retained in filterAllInactiveCards when includeDeactivated: true.
  • Confirmed that closed cards (STATE_CLOSED) and standard inactive cards continue to be filtered out as expected.
  • Clean pass on TypeScript check and linter with zero errors.

Branch and commit ready for review on fork: https://github.com/Mister124x/App/commit/036d1731e471b3602f565a571f1fa21ae336bb55

Mister124x avatar Sep 17 '26 08:09 Mister124x

@abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Sep 17 '26 21:09 melvin-bot[bot]

@abdulrahuman5196 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

melvin-bot[bot] avatar Sep 21 '26 21:09 melvin-bot[bot]

@abdulrahuman5196 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

melvin-bot[bot] avatar Sep 23 '26 21:09 melvin-bot[bot]

Hi, Will check and update here once done

abdulrahuman5196 avatar Sep 24 '26 15:09 abdulrahuman5196

@abdulrahuman5196 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!

melvin-bot[bot] avatar Sep 28 '26 21:09 melvin-bot[bot]

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

melvin-bot[bot] avatar Sep 29 '26 21:09 melvin-bot[bot]

@abdulrahuman5196 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

melvin-bot[bot] avatar Oct 01 '26 21:10 melvin-bot[bot]

@abdulrahuman5196 10 days overdue. Is anyone even seeing these? Hello?

melvin-bot[bot] avatar Oct 05 '26 22:10 melvin-bot[bot]

Hi, Will check and update here once done

abdulrahuman5196 avatar Oct 06 '26 05:10 abdulrahuman5196

@abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Oct 09 '26 21:10 melvin-bot[bot]

@abdulrahuman5196 this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

melvin-bot[bot] avatar Oct 12 '26 21:10 melvin-bot[bot]

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

melvin-bot[bot] avatar Oct 13 '26 21:10 melvin-bot[bot]

@abdulrahuman5196 Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

melvin-bot[bot] avatar Oct 15 '26 21:10 melvin-bot[bot]

@abdulrahuman5196 12 days overdue now... This issue's end is nigh!

melvin-bot[bot] avatar Oct 19 '26 21:10 melvin-bot[bot]

This issue has not been updated in over 14 days. @abdulrahuman5196 eroding to Weekly issue.

melvin-bot[bot] avatar Oct 22 '26 21:10 melvin-bot[bot]