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
[Due for payment 2026-09-09] Remove hold is offered as the primary action after delete un-held expense offline #98263
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
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
Go offline (DevTools → Network → Offline, or the app's force-offline toggle)
While offline, delete the un-held expense from the report
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)
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.
useReportPrimaryAction.ts:54 filters out pending-delete transactions with no offline check, so getReportPrimaryAction receives only [T1].
With just the held T1, hasOnlyHeldExpenses returns true, so the report is treated as "all expenses held."
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
Offline delete does set pendingAction: DELETE on the deleted transaction and its IOU action (DeleteMoneyRequest.ts:131-149), so isTransactionPendingDelete(T2) is true and T2 is filtered at line 54.
Net effect: isRemoveHoldAction(...) → false (correct), but isPayActionWithAllExpensesHeld && expensesToHold.length → truthy → REMOVE_HOLD.
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.
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:
That filtered array is then used for two different purposes:
deciding actions for the currently visible/non-deleted expenses; and
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:
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:
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Offline: held T1 + unheld T2 pending delete → primary action is not REMOVE_HOLD.
Online/synced: T2 is actually removed and only held T1 remains → REMOVE_HOLD is offered.
Offline: held T1 + held T2 pending delete → held-state logic remains deterministic and does not duplicate actions.
Offline: a pending-delete transaction does not re-enter Pay/Approve/Submit eligibility or other visible-transaction calculations.
Offline: pending-delete IOU action counting continues to protect the existing isRemoveHoldAction() branch.
Reconnect transition: the action recomputes from the offline held-state view to the online filtered view without requiring a page reload.
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.
so offline getReportPrimaryAction only gets the held transaction and hasOnlyHeldExpenses returns true, which skips SUBMIT/PAY and falls through to the expensesToHold branch
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
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.
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:
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.
Expensify/App#82968 (2026-02-20) added the unconditional nonPendingDeleteTransactions filter (commit 462da74). It's the precondition, but on its own it was harmless — at that time hasOnlyHeldExpenses ignored the passed array entirely.
[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
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
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.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
applause-bot commentedon Aug 11, 2026
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
MelvinBot commentedon Aug 11, 2026
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):
useReportPrimaryAction.ts:54filters out pending-delete transactions with no offline check, sogetReportPrimaryActionreceives only[T1].hasOnlyHeldExpensesreturnstrue, so the report is treated as "all expenses held."REMOVE_HOLDis returned via the second branch of the OR atReportPrimaryActionUtils.ts:529—isPayActionWithAllExpensesHeld && expensesToHold.length— which is not offline-aware.PR #95776 added
isOfflinethreading 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 returnsfalse). The transaction-array path that feeds the second branch still silently drops T2, so the fix was incomplete.Evidence chain
pendingAction: DELETEon the deleted transaction and its IOU action (DeleteMoneyRequest.ts:131-149), soisTransactionPendingDelete(T2)istrueand T2 is filtered at line 54.getOneTransactionThreadReportAction(ReportActionsUtils.ts:1976); thehasOnlyHeldExpenses/getAllExpensesToHoldIfApplicablepath never received it.isRemoveHoldAction(...)→false(correct), butisPayActionWithAllExpensesHeld && expensesToHold.length→ truthy →REMOVE_HOLD.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 whenisOfflineis true (drop them only when online). With T2 retained offline,hasOnlyHeldExpenses([T1, T2])isfalse, so the report is correctly not "all held" andREMOVE_HOLDis 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
isOfflineinto 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.
melvin-bot commentedon Aug 11, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (
External)melvin-bot commentedon Aug 11, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022087096802927891558
skrohan5016-coder commentedon Aug 14, 2026
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 everypendingAction: DELETEtransaction before callinggetReportPrimaryAction(), regardless of network state:That filtered array is then used for two different purposes:
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 secondREMOVE_HOLDbranch (isPayActionWithAllExpensesHeld && expensesToHold.length) fires.The existing offline-aware fix in
isRemoveHoldAction()only protects the first branch. The all-held/expensesToHoldpath 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:
Pass the normal filtered list as
reportTransactions, and pass the second list under an explicit name such asreportTransactionsForHeldState.Inside
getReportPrimaryAction():reportTransactionsfor Pay, Approve, Submit, Mark as cash, duplicate review, violation checks, and other actions that operate on the current optimistic/visible report contents;reportTransactionsForHeldStateonly for:hasOnlyHeldExpenses()/allExpensesHeld;getAllExpensesToHoldIfApplicable()and theexpensesToHoldvalue 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
reportTransactionsForHeldStatecollapses back to the non-pending-delete list once the delete can sync.The parameter can default to
reportTransactionsingetReportPrimaryAction()so existing direct callers/tests do not need unrelated changes:What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
REMOVE_HOLD.REMOVE_HOLDis offered.isRemoveHoldAction()branch.A regression test should exercise
getReportPrimaryAction()with both arrays, not just mockhasOnlyHeldExpenses, so both Remove-hold branches are covered.What alternative solutions did you explore? (Optional)
REMOVE_HOLDcondition: brittle becauseallExpensesHeldandexpensesToHoldare reused in multiple branches.melvin-bot commentedon Aug 14, 2026
@Ollyws Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Aug 18, 2026
@Ollyws 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
yusufdeveloper2903 commentedon Aug 20, 2026
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
App/src/hooks/useReportPrimaryAction.ts
Line 54 in e6745c3
so offline
getReportPrimaryActiononly gets the held transaction andhasOnlyHeldExpensesreturnstrue, which skipsSUBMIT/PAYand falls through to theexpensesToHoldbranchApp/src/libs/ReportPrimaryActionUtils.ts
Line 571 in e6745c3
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
App/src/components/ReportActionItem/MoneyReportView.tsx
Line 116 in e6745c3
isOfflineis already available in the hookso
hasOnlyHeldExpensesisfalseoffline and the report keeps offeringSubmit, and once the delete syncs the transaction is removed from Onyx soRemove holdappears as expected.We should do the same for the secondary actions which have the same unconditional filter
App/src/components/MoneyReportHeaderActions/MoneyReportHeaderSecondaryActions.tsx
Line 153 in e6745c3
Note: #95776 made only
isRemoveHoldActionoffline aware throughgetOneTransactionThreadReportID, so the first clause of theREMOVE_HOLDcondition is already correct and it is theexpensesToHoldfallback that fires.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can test that
getReportPrimaryActiondoesn't returnREMOVE_HOLDfor 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.
Ollyws commentedon Aug 20, 2026
@MelvinBot What would this code look like?
25 remaining items
melvin-bot commentedon Sep 8, 2026
Payment Summary
Resolving PRs:
Keep pending-delete transactions offline so Remove hold isn't the primary action after offline delete #99096
Reviewer: @Ollyws owed $250 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Sep 10, 2026
Payment Summary
Contributor+: @Ollyws due $250 via NewDot
@Ollyws plz complete the Contributor+ checklist and tag me in a post once you have. Thx
Ollyws commentedon Sep 14, 2026
@MelvinBot what PR caused this?
MelvinBot commentedon Sep 14, 2026
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
hasOnlyHeldExpensesfrom reading the report's transactions out of Onyx byreportIDto using the array the caller passes in (commit9c7879f). 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:
hasOnlyHeldExpenses(reportID)→getReportTransactions(reportID)→[T1 held, T2 unheld pending-delete]→false. NoREMOVE_HOLD.After #89387 — it takes the caller's array:
and the same PR changed the
isPayActionWithAllExpensesHeldcall site the same way.reportTransactionsthere isnonPendingDeleteTransactions, so it's[T1]→true→expensesToHoldnon-empty → theisPayActionWithAllExpensesHeld && expensesToHold.lengthbranch returnsREMOVE_HOLD.Current lines:
ReportUtils.ts:11650,ReportPrimaryActionUtils.ts:475,ReportPrimaryActionUtils.ts:520.Two related PRs that are not the cause:
nonPendingDeleteTransactionsfilter (commit462da74). It's the precondition, but on its own it was harmless — at that timehasOnlyHeldExpensesignored the passed array entirely.isOfflineintoisRemoveHoldAction, fixing the first clause of theREMOVE_HOLDcondition; theexpensesToHoldclause was left broken, which is what Expensify/App#99096 then fixed.getOneTransactionThreadReportActionwas already offline-aware before Part 3: Remove Onyx.connect() for the key: ONYXKEYS.NETWORK in src/libs/ReportActionsUtils.ts #95776 (via the deprecated networkOnyx.connect), so Part 3: Remove Onyx.connect() for the key: ONYXKEYS.NETWORK in src/libs/ReportActionsUtils.ts #95776 didn't introduce anything.fix: use live transactions for held-expense approval/pay flows
Ollyws commentedon Sep 14, 2026
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[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.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/681756
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-b807-accd-67eb-a3f8ec03f4a4Ollyws commentedon Sep 14, 2026
@mallenexpensify checklist done and payment requested.
flaviadefaria commentedon Sep 22, 2026
Approved: @Ollyws due $250 via NewDot