Skip to content

[Due for payment 2026-09-09] Remove hold is offered as the primary action after delete un-held expense offline #98263

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.52-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #95776
Email or phone of affected tester (no customers): lekima20+68808@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Win 11/Chrome
App Component: Money Requests

Action Performed:

Precondition: Create 2 expenses to the workspace chat

  1. Open https://staging.new.expensify.com/
  2. Navigate to the report having 2 expenses
  3. Hold one expense
  4. Go offline (DevTools → Network → Offline, or the app's force-offline toggle)
  5. While offline, delete the un-held expense from the report
  6. While still offline, open the report header

Expected Result:

Verify Remove hold is not offered as the primary action, and Hold/Remove hold secondary options behave as on main (the pending-delete expense still counts as a second transaction, so the report is not a one-transaction report)

Actual Result:

Remove hold is offered as the primary action

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7230729_1786423490110.Recording__2392.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7230729

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    Daily
    Bug
    on Aug 11, 2026
  2. applause-bot commented on Aug 11, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/ec58ad0ecfbd44f0b5f4ec68be306bb9203e89166d95874d0da85d8de3a677e5

  3. MelvinBot commented on Aug 11, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The primary-action logic strips all pending-delete transactions from the transaction list before computing the action, and it does so unconditionally — even while offline. So the report looks like a single, all-held expense report and returns REMOVE_HOLD.

    Walking the repro (T1 = held, T2 = un-held → deleted offline):

    1. useReportPrimaryAction.ts:54 filters out pending-delete transactions with no offline check, so getReportPrimaryAction receives only [T1].
    2. With just the held T1, hasOnlyHeldExpenses returns true, so the report is treated as "all expenses held."
    3. REMOVE_HOLD is returned via the second branch of the OR at ReportPrimaryActionUtils.ts:529 — isPayActionWithAllExpensesHeld && expensesToHold.length — which is not offline-aware.

    PR #95776 added isOffline threading to fix exactly this scenario, but it only patched the first branch (isRemoveHoldAction → getOneTransactionThreadReportID, which now correctly counts the offline pending-delete IOU action and returns false). The transaction-array path that feeds the second branch still silently drops T2, so the fix was incomplete.

    Evidence chain

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

    Make the pending-delete filter offline-aware so a pending-delete expense still counts as a real transaction while offline — mirroring the offline logic PR #95776 already added to the one-transaction-report count. Concretely, at useReportPrimaryAction.ts:54, keep pending-delete transactions when isOffline is true (drop them only when online). With T2 retained offline, hasOnlyHeldExpenses([T1, T2]) is false, so the report is correctly not "all held" and REMOVE_HOLD is not returned until the deletion syncs online.

    Before merging, confirm this doesn't regress other offline primary actions that rely on the filtered list (Approve, Pay, Mark as cash, etc.) — reviewers should sanity-check those flows while offline, since line 54 feeds all of them.

    What alternative solutions did you explore? (Optional)

    Instead of changing the shared filter, thread isOffline into just the held-expense checks (hasOnlyHeldExpenses / getAllExpensesToHoldIfApplicable / the second OR branch) so only the Remove-hold decision accounts for offline pending-delete transactions. This is narrower and lower-risk for the other actions, but touches more call sites.


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

  4. added
    External
    on Aug 11, 2026
  5. melvin-bot commented on Aug 11, 2026

    @melvin-bot

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

  6. melvin-bot commented on Aug 11, 2026

    @melvin-bot
  7. skrohan5016-coder commented on Aug 14, 2026

    @skrohan5016-coder

    Proposal

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

    After an unheld expense is deleted offline from a report that also contains a held expense, the report incorrectly offers Remove hold. The queued deletion must not make the report look like an all-held report before the deletion is acknowledged online.

    What is the root cause of that problem?

    useReportPrimaryAction() currently removes every pendingAction: DELETE transaction before calling getReportPrimaryAction(), regardless of network state:

    const nonPendingDeleteTransactions = Object.values(reportTransactions).filter((t) => !isTransactionPendingDelete(t));

    That filtered array is then used for two different purposes:

    1. deciding actions for the currently visible/non-deleted expenses; and
    2. deciding whether the server-backed report is all held.

    Those purposes diverge while offline. In the repro, the unheld transaction is hidden optimistically but still belongs to the report until its delete command syncs. Removing it from the held-state calculation leaves only the held transaction, so hasOnlyHeldExpenses() becomes true and the second REMOVE_HOLD branch (isPayActionWithAllExpensesHeld && expensesToHold.length) fires.

    The existing offline-aware fix in isRemoveHoldAction() only protects the first branch. The all-held/expensesToHold path still receives the already-filtered array.

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

    Use two transaction views instead of changing the shared filter for every primary action:

    const allReportTransactions = Object.values(reportTransactions);
    const nonPendingDeleteTransactions = allReportTransactions.filter((transaction) => !isTransactionPendingDelete(transaction));
    const transactionsForHeldState = isOffline ? allReportTransactions : nonPendingDeleteTransactions;

    Pass the normal filtered list as reportTransactions, and pass the second list under an explicit name such as reportTransactionsForHeldState.

    Inside getReportPrimaryAction():

    • continue using reportTransactions for Pay, Approve, Submit, Mark as cash, duplicate review, violation checks, and other actions that operate on the current optimistic/visible report contents;
    • use reportTransactionsForHeldState only for:
      • hasOnlyHeldExpenses() / allExpensesHeld;
      • getAllExpensesToHoldIfApplicable() and the expensesToHold value that feeds the Remove-hold branches.

    This is safer than retaining pending-delete transactions in the only list passed to every action. The current filter feeds all primary-action decisions; broadly making it offline-aware could cause invisible, queued-for-deletion expenses to affect payment eligibility, approval, duplicate review, totals, violations, or single-transaction actions.

    Online behavior remains unchanged because reportTransactionsForHeldState collapses back to the non-pending-delete list once the delete can sync.

    The parameter can default to reportTransactions in getReportPrimaryAction() so existing direct callers/tests do not need unrelated changes:

    const transactionsForHeldState = reportTransactionsForHeldState ?? reportTransactions;

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    1. Offline: held T1 + unheld T2 pending delete → primary action is not REMOVE_HOLD.
    2. Online/synced: T2 is actually removed and only held T1 remains → REMOVE_HOLD is offered.
    3. Offline: held T1 + held T2 pending delete → held-state logic remains deterministic and does not duplicate actions.
    4. Offline: a pending-delete transaction does not re-enter Pay/Approve/Submit eligibility or other visible-transaction calculations.
    5. Offline: pending-delete IOU action counting continues to protect the existing isRemoveHoldAction() branch.
    6. Reconnect transition: the action recomputes from the offline held-state view to the online filtered view without requiring a page reload.
    7. Empty/all-pending-delete report does not surface an action based solely on invisible transactions.

    A regression test should exercise getReportPrimaryAction() with both arrays, not just mock hasOnlyHeldExpenses, so both Remove-hold branches are covered.

    What alternative solutions did you explore? (Optional)

    • Keep pending-delete transactions in the shared list whenever offline: fixes the repro but is unnecessarily broad and can regress unrelated primary actions.
    • Patch only the final REMOVE_HOLD condition: brittle because allExpensesHeld and expensesToHold are reused in multiple branches.
    • Wait for the backend response: leaves the incorrect offline action visible and defeats the optimistic/offline model.
  8. melvin-bot commented on Aug 14, 2026

    @melvin-bot

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

  9. melvin-bot commented on Aug 18, 2026

    @melvin-bot

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

  10. yusufdeveloper2903 commented on Aug 20, 2026

    @yusufdeveloper2903
    Contributor

    Proposal

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

    Remove hold is offered as the primary action after deleting an un-held expense offline

    What is the root cause of that problem?

    We are filtering out pending delete transactions unconditionally here

    const nonPendingDeleteTransactions = Object.values(reportTransactions).filter((t) => !isTransactionPendingDelete(t));

    so offline getReportPrimaryAction only gets the held transaction and hasOnlyHeldExpenses returns true, which skips SUBMIT/PAY and falls through to the expensesToHold branch
    if (expensesToHold.length) {

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

    We should keep pending delete transactions while offline, just like we already do for the visible transaction list of the report

    const visibleTransactions = transactions.filter((transaction) => isOffline || !isTransactionPendingDelete(transaction));

    isOffline is already available in the hook

    const nonPendingDeleteTransactions = Object.values(reportTransactions).filter((t) => isOffline || !isTransactionPendingDelete(t));
    

    so hasOnlyHeldExpenses is false offline and the report keeps offering Submit, and once the delete syncs the transaction is removed from Onyx so Remove hold appears as expected.

    We should do the same for the secondary actions which have the same unconditional filter

    const nonPendingDeleteTransactions = Object.values(reportTransactions).filter((t) => t.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);

    Note: #95776 made only isRemoveHoldAction offline aware through getOneTransactionThreadReportID, so the first clause of the REMOVE_HOLD condition is already correct and it is the expensesToHold fallback that fires.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We can test that getReportPrimaryAction doesn't return REMOVE_HOLD for a report with one held transaction and one un-held pending delete transaction while offline.

    What alternative solutions did you explore? (Optional)

    We could pass a separate transaction array used only for the held state checks but that isn't needed as the pending delete expense is still rendered in the report while offline, so the other actions should count it as a real transaction too.

  11. Ollyws commented on Aug 20, 2026

    @Ollyws
    Contributor

    @MelvinBot What would this code look like?

  12. 25 remaining items

  13. melvin-bot commented on Sep 8, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  14. mallenexpensify commented on Sep 10, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Ollyws due $250 via NewDot

    @Ollyws plz complete the Contributor+ checklist and tag me in a post once you have. Thx

  15. Ollyws commented on Sep 14, 2026

    @Ollyws
    Contributor

    @MelvinBot what PR caused this?

  16. MelvinBot commented on Sep 14, 2026

    @MelvinBot
    Contributor

    Expensify/App#89387 — "fix: use live transactions for held-expense approval/pay flows" (merged 2026-05-20, first shipped in 9.3.79).

    It changed hasOnlyHeldExpenses from reading the report's transactions out of Onyx by reportID to using the array the caller passes in (commit 9c7879f). The caller in the primary-action path passes an array that already has pending-delete transactions filtered out, so offline the held-state check stopped seeing the deleted expense and the report started looking "all held" → REMOVE_HOLD.

    Evidence

    Before #89387 — the held check read Onyx directly, which still contains the offline-deleted transaction:

    if (!report || !reportActions || !hasOnlyHeldExpenses(report?.reportID)) {

    hasOnlyHeldExpenses(reportID) → getReportTransactions(reportID) → [T1 held, T2 unheld pending-delete] → false. No REMOVE_HOLD.

    After #89387 — it takes the caller's array:

    if (!report || !reportActions || !hasOnlyHeldExpenses(reportTransactions, report?.reportID)) {

    and the same PR changed the isPayActionWithAllExpensesHeld call site the same way. reportTransactions there is nonPendingDeleteTransactions, so it's [T1] → true → expensesToHold non-empty → the isPayActionWithAllExpensesHeld && expensesToHold.length branch returns REMOVE_HOLD.

    Current lines: ReportUtils.ts:11650, ReportPrimaryActionUtils.ts:475, ReportPrimaryActionUtils.ts:520.

    Two related PRs that are not the cause:

  17. Ollyws commented on Sep 14, 2026

    @Ollyws
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production
    • 2b. Reported on staging (deploy blocker)
    • 2c. Reported on both staging and production
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: 9c7879f#r200312123

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template

    Regression Test Proposal

    Precondition:

    Test:

    1. Create two manual expenses (for example, Test Merchant A for 10.00 and Test Merchant B for 20.00) on the same workspace expense report.
    2. Submit the report. Verify the report header primary action is Approve.
    3. Open Test Merchant A, then More → Hold, enter a reason, and confirm the hold.
    4. Go back to the report. Verify the header primary action is still Approve (one of two expenses is held, so the report is not all-held).
    5. Go to Account → Troubleshoot and turn on Force offline. Verify the "You appear to be offline." banner appears.
    6. While offline, open Test Merchant B (the un-held expense) and delete it via More → Delete.
    7. Go back to the report while still offline and look at the report header.
    8. Verify the primary action button is Approve and is not Remove hold.
    9. Verify Test Merchant B is still listed in the report, rendered struck-through/greyed as a pending delete, so the report is not collapsed into a one-transaction report.
    10. Open the report header More menu and verify Remove hold is still offered there as a secondary action (correct — Test Merchant A is genuinely still held).
    11. Turn Force offline back off and wait for the delete to sync. Verify Test Merchant B disappears and the header primary action becomes Remove hold, since the report now contains only the held expense.
    

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-b807-accd-67eb-a3f8ec03f4a4
  18. Ollyws commented on Sep 14, 2026

    @Ollyws
    Contributor

    @mallenexpensify checklist done and payment requested.

  19. added
    Daily
    and removed
    Daily
    on Sep 14, 2026
  20. flaviadefaria commented on Sep 22, 2026

    @flaviadefaria
    Contributor

    Approved: @Ollyws due $250 via NewDot

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions