Skip to content

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

Open

Description

@vincdargento

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: 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
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7242973_1787716331898.bandicam_2026-08-26_10-43-43-307.mp4
Issue OwnerCurrent Issue Owner: @abdulrahuman5196

Activity

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

    @MelvinBot
    Contributor

    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 #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 #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

    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

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 14, 2026
  4. melvin-bot commented on Sep 14, 2026

    @melvin-bot

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

  5. melvin-bot commented on Sep 14, 2026

    @melvin-bot

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

  6. Mister124x commented on Sep 14, 2026

    @Mister124x

    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.

  7. Mister124x commented on Sep 17, 2026

    @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:
    Mister124x@036d173

  8. melvin-bot commented on Sep 17, 2026

    @melvin-bot

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

  9. melvin-bot commented on Sep 21, 2026

    @melvin-bot

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

  10. melvin-bot commented on Sep 23, 2026

    @melvin-bot

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

  11. abdulrahuman5196 commented on Sep 24, 2026

    @abdulrahuman5196
    Contributor

    Hi, Will check and update here once done

  12. 16 remaining items

  13. melvin-bot commented on Oct 22, 2026

    @melvin-bot

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

  14. melvin-bot commented on Nov 3, 2026

    @melvin-bot

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

  15. melvin-bot commented on Nov 3, 2026

    @melvin-bot

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

  16. melvin-bot commented on Nov 3, 2026

    @melvin-bot

    @abdulrahuman5196 Huh... This is 4 days overdue. Who can take care of this?

  17. melvin-bot commented on Nov 4, 2026

    @melvin-bot

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

  18. melvin-bot commented on Nov 5, 2026

    @melvin-bot

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

  19. jeffrey-graham commented on Nov 7, 2026

    @jeffrey-graham
  20. melvin-bot commented on Nov 7, 2026

    @melvin-bot
  21. melvin-bot commented on Nov 9, 2026

    @melvin-bot

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

  22. melvin-bot commented on Nov 11, 2026

    @melvin-bot

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

  23. cocvn157 commented on Nov 14, 2026

    @cocvn157

    Proposal

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

    When a workspace admin sets an Expensify Card's Smart Limit to $0 (or sets the card limit to $0 in Expensify Classic), the backend transitions that card to STATE_DEACTIVATED (5), causing the card to disappear from the Workspace > Expensify Card management list in New Expensify so admins can no longer view or manage it.

    What is the root cause of that problem?

    1. Why isActiveCard in src/libs/CardUtils.ts:1546-1551 drops admin-zeroed $0-limit Expensify Cards:
      • WorkspaceExpensifyCardPage selects workspace cards via filterInactiveCardsForWorkspace (src/libs/CardUtils.ts:1591-1593), which calls filterAllInactiveCards(cardsList, true, true) -> isActiveCard(card, true).
      • The JSDoc directly above filterAllInactiveCards (src/libs/CardUtils.ts:1554-1558) explicitly documents the intended contract:

        "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, isActiveCard at lines 1546–1551 currently only checks includeDeactivated when card.state === CONST.EXPENSIFY_CARD.STATE.STATE_SUSPENDED (7):
        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;
        }
      • Meanwhile, the dedicated predicate isCardWithCustomZeroLimit(card) already exists in src/libs/CardUtils.ts:2123-2125:
        function isCardWithCustomZeroLimit(card: Card): boolean {
            return !!card.nameValuePairs?.hasCustomUnapprovedExpenseLimit && card.nameValuePairs?.unapprovedExpenseLimit === 0;
        }
      • Because PR Allow $0 as valid card limit when editing Expensify Card #90540 removed the STATE_DEACTIVATED check from isActiveCard to prevent genuinely terminated/deactivated cards (Issue [Due for payment 2026-05-28] [$250] Expensify Card - Error when try to edit the limit of the first assigned card #90487) from showing up, isActiveCard now unconditionally rejects all STATE_DEACTIVATED (5) cards—even when includeDeactivated is true and isCardWithCustomZeroLimit(card) is true.

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

    Rather than blindly keeping every STATE_DEACTIVATED card (which would re-introduce the #90487 regression for genuinely deactivated cards that cannot be edited), we should gate the STATE_DEACTIVATED inclusion in isActiveCard on includeDeactivated && isCardWithCustomZeroLimit(card) (for Expensify Cards):

    1. Update isActiveCard in src/libs/CardUtils.ts:1546-1551:

      function isActiveCard(card: Card, includeDeactivated = false): boolean {
          if (card.state === CONST.EXPENSIFY_CARD.STATE.STATE_SUSPENDED) {
              return !!card.nameValuePairs?.frozen || includeDeactivated;
          }
          if (card.state === CONST.EXPENSIFY_CARD.STATE.STATE_DEACTIVATED) {
              return includeDeactivated && isExpensifyCard(card) && isCardWithCustomZeroLimit(card);
          }
          return card.state !== CONST.EXPENSIFY_CARD.STATE.CLOSED;
      }
    2. Update Unit Tests in tests/unit/CardUtilsTest.ts:

      • Update the adminZeroedDeactivated test cases in tests/unit/CardUtilsTest.ts so that:
        • filterInactiveCards(cards) (includeDeactivated = false) excludes adminZeroedDeactivated.
        • filterInactiveCardsForWorkspace(cards) / filterAllInactiveCards(cards, true) (includeDeactivated = true) retains adminZeroedDeactivated while still excluding non-zero-limit STATE_DEACTIVATED cards and CLOSED cards.

    What alternative solutions did you explore? (Optional)

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorOverdue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions