Skip to content

Bug: Admins unable to delete imported corp card expenses on Personal liability feeds (regression from #69630) #92784

Closed

Description

@melvin-bot

Summary

Admins at REDACTED (and likely other domains) can no longer delete imported company card (SVB feed) expenses, even though their feed's Liability Type is set to Personal. This is a regression — the behavior worked previously.

Affected accounts: REDACTED — both domain admins on REDACTED, SVB card feed.


Root Cause Analysis

The gate today (src/libs/ReportUtils.ts)

function canDeleteCardTransactionByLiabilityType(transaction): boolean {
    const isCardTransaction = isCardTransactionTransactionUtils(transaction);
    if (!isCardTransaction) {
        return true; // non-card → always deletable
    }
    return transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.ALLOW;
}

This returns true only when liabilityType === "allow". If liabilityType is "restrict" (corporate) or empty/undefined, Delete is hidden.

The regression: PR #69630 (merged 2025-09-17)

#69630 — "Hide delete button for unreported card expense imported with deleting disabled" broadened the restriction in a breaking way:

Before #69630, the expense-report path used a narrow block:

isSingleTransaction && isCardTransaction(t) && t.comment.liabilityType === LIABILITY_TYPE.RESTRICT

→ "block deletion only if liabilityType is explicitly RESTRICT"

After #69630, it uses the general gate:

!canDeleteCardTransactionByLiabilityType(t)

→ "allow deletion only if liabilityType is explicitly ALLOW"

Two consequences:

  1. Semantic flip: Any transaction with an empty/undefined liabilityType flipped from deletable → not deletable.
  2. Removed the isSingleTransaction guard, so multi-transaction expense reports are now gated too. Also extended the gate to unreported and track-expense card transactions.

Why REDACTED is affected

Log investigation over the last 90 days (back to ~2026-03-18) shows:

  • Zero Domain_SetCompanyCardSettings writes for REDACTED — the feed's liability type was never changed.
  • Zero POLICYCHANGELOG_UPDATE_CARD_FEED_LIABILITY entries for the domain.

The feed setting didn't move. The code reading it got stricter. If REDACTED'S SVB-imported transactions carry an empty/missing comment.liabilityType (rather than "allow"), post-#69630 the Delete button is hidden even though the admin's feed is configured as Personal liability.


Hypothesis / Next Step

The backend may not be stamping liabilityType: "allow" on SVB/upload-feed imported transactions when the feed is set to Personal liability. If that value is missing at import time, the App-side gate (post-#69630) treats it as non-deletable.

Recommended investigation:

  1. Pull comment.liabilityType on a few of REDACTED'S SVB-imported transactions (Onyx/transaction logs) to confirm the value is empty/undefined rather than "allow".
  2. If confirmed missing: fix the backend to stamp liabilityType: "allow" on imported transactions for Personal-liability feeds, and/or update canDeleteCardTransactionByLiabilityType to treat a missing liabilityType as ALLOW when the feed is configured as Personal.

Related PRs

  • #56877 — Original feature introduction (2025-03-05)
  • #62434 — Behavior-neutral refactor (2025-07-02)
  • #69630 — Regression source (2025-09-17)

Activity

  1. added
    Internal
    Bug
    on Jun 5, 2026
  2. lydiabarclay commented on Jun 5, 2026

    @lydiabarclay
    Contributor

    I asked Melv to make me a GH to investigate a customer issue, and they made it in the App repo and included customer info 😅 I have since redacted the info, and I'm going to close this.

  3. MelvinBot commented on Jun 5, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    A breaking semantic flip in PR #69630 (merged 2025-09-17). It replaced a deny-list ("block deletion only when the card's liability is explicitly corporate") with an allow-list ("allow deletion only when liability is explicitly personal").

    The gate is canDeleteCardTransactionByLiabilityType:

    return transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.ALLOW; // 'personal'

    Because LIABILITY_TYPE.ALLOW is the string 'personal' (CONST), the Delete button now shows only when the transaction's comment.liabilityType is exactly 'personal'. Any card transaction whose liabilityType is empty/undefined flipped from deletable → not deletable, regardless of how the feed is configured. comment.liabilityType is a backend-stamped field — the App only ever reads it; nothing in App writes it onto a transaction. So if SVB-imported transactions arrive without liabilityType stamped, the post-#69630 allow-list hides Delete even though the feed's liability is Personal.

    Code evidence — exactly what #69630 changed

    Before #69630 the expense-report path blocked only on explicit corporate liability:

    isSingleTransaction && isCardTransaction(t) && t.comment.liabilityType === LIABILITY_TYPE.RESTRICT // 'corporate'

    After #69630 the same path uses the new allow-list gate (ReportUtils.ts:3058-3061):

    if (isSingleTransaction && !canCardTransactionBeDeleted) { return false; }

    The check was additionally extended to the unreported and track-expense card paths. #69630 implemented the goal of #66724 ("hide Delete for corporate-liability card expenses"), but an allow-list was stricter than that goal required and caught the empty/undefined case as collateral.

    The helper is the single source of truth for four call sites — canDeleteMoneyRequestReport, canDeleteReportAction, DynamicReportDetailsPage, and useSelectedTransactionsActions — so all four inherited the flip.

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

    Restore the original deny-list semantics in the one gate so a card transaction is deletable unless it is explicitly corporate-liability:

    // canDeleteCardTransactionByLiabilityType (ReportUtils.ts)
    return transaction?.comment?.liabilityType !== CONST.TRANSACTION.LIABILITY_TYPE.RESTRICT; // 'corporate'

    This still satisfies #66724 (corporate-liability feeds keep Delete hidden) while restoring deletion for Personal and empty/undefined liabilityType, fixing the regression for every affected user — not just one domain. It's a single-line change inherited by all four call sites.

    What alternative solutions did you explore? (Optional)

    • Backend stamping fix (outside App): ensure the import pipeline stamps liabilityType: 'personal' on transactions imported into Personal-liability feeds. This is the correct data fix but lives in Auth/Web-Expensify, not App, so a contributor cannot make it here.
    • Which fix is needed depends on the stored value — and that has not been confirmed. If the affected transactions store an empty liabilityType, the App-side change above fully resolves it. If they instead store 'corporate' despite a Personal feed, that is a backend stamping bug and the App change won't help. Next verification step: read comment.liabilityType on a sample of the affected SVB transactions. The existing investigation already confirmed the feed setting never changed (no Domain_SetCompanyCardSettings / liability-changelog writes in 90 days), so a stale/missing per-transaction stamp is the most likely culprit.
    Confidence & related

    Confidence: Medium-High. The regression mechanism and its source PR are confirmed in code. What's unconfirmed is the exact stored liabilityType on the affected transactions, which determines whether the App-side fix alone is sufficient.

    Related PRs/issues: #56877 (original feature), #62434 (neutral refactor), #69630 (regression source), #66724 (the issue #69630 was solving).


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugDailyInternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions