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
[$250] Expense-Deleted report in offline is shown as empty report with unexpected error message #83176
Version Number: V9.3.24-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#82968 Email or phone of affected tester (no customers):dreamnitethedragon@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Redminote 10S Android 13 App Component: Money Requests
Action Performed:
Launch app
Create workspace and enable all options in workflow ( submission frequency, approval and payment)
Go to workspace chat
Create 2 distance manual expense
Go offline
Long press and delete first expense
Open the second expense and delete
Tap more - delete report
Go online
Navigate back and open workspace chat
Note empty report with unexpected error message is shown
Tap add expense dropdown and create a distance manual expense
Note in deleted report user allowed to create expense and it shows unexpected error.
Close the error
Open the expense and note error is shown
Expected Result:
Deleted report in offline must not be shown as empty report with unexpected error message.
Actual Result:
Deleted report in offline is shown as empty report with unexpected error message.
When expenses are deleted individually and then the report is deleted while offline, three commands are queued: DeleteMoneyRequest(A), DeleteMoneyRequest(B), DeleteAppReport. When the app goes online, the SequentialQueue processes them in order. The server may auto-delete the IOU report when the last transaction is removed via DeleteMoneyRequest(B). Then DeleteAppReport fails (report already gone server-side), and its failureData restores the full report object back into Onyx via Onyx.METHOD.SET — creating a ghost empty report.
The error message comes from DeleteMoneyRequest's failureData applying iou.error.genericDeleteFailureMessage to the report actions.
A key contributing factor: shouldDeleteIOUReport is always false for individual deletes because getReportTransactions counts all transactions including those with pendingAction: DELETE (DeleteMoneyRequest.ts:120). This means neither DeleteMoneyRequest call tells the server to clean up the report — the server does it on its own when the last transaction is removed, then DeleteAppReport fails against an already-deleted resource.
What changes do you think we should make in order to solve the problem?
Add a checkAndFixConflictingRequest handler to DeleteAppReport that detects when all transactions on the report have already been deleted by preceding DeleteMoneyRequest commands in the queue. If the report would already be empty/deleted server-side, remove the DeleteAppReport request from the queue entirely (since the server already handled cleanup).
Alternatively, update DeleteAppReport's failureData to not blindly restore the report — instead of Onyx.METHOD.SET with the full original report, it should set the report to null when the failure is due to a "not found" response (the report was already cleaned up server-side). This would prevent the ghost report from being recreated in Onyx.
What alternative solutions did you explore? (Optional)
Fix shouldDeleteIOUReport calculation — filter out transactions with pendingAction: DELETE in the count so the second DeleteMoneyRequest correctly determines it should delete the IOU report. This would prevent DeleteAppReport from being needed at all, but changes behavior broadly and could have side effects on other flows.
Skip DeleteAppReport client-side — when calling deleteAppReport, check if all transactions already have pendingAction: DELETE and skip the API call entirely. Simpler but less robust since it only handles this specific ordering.
User creates 2 expenses → IOU report with 2 transactions
Goes offline
Deletes expense A → DELETE_MONEY_REQUEST queued (shouldDeleteIOUReport=false)
Deletes expense B → DELETE_MONEY_REQUEST queued (shouldDeleteIOUReport=false — transaction A still counted)
Deletes report → DELETE_APP_REPORT queued, failureData captures current report state
Goes online → queue flushes in order
Server processes both DeleteMoneyRequest calls successfully, auto-cleans IOU report
Server returns error for DeleteAppReport (report gone) → failureData SETs full report back into Onyx
Ghost empty report appears with "unexpected error" message
Possibly related:#87065 (restored expense detail preview empty after going back online) and #86710 (Onyx data not synced with server / persisted requests).
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
changed the title [-]Expense-Deleted report in offline is shown as empty report with unexpected error message[/-][+][$250] Expense-Deleted report in offline is shown as empty report with unexpected error message[/+]on Apr 13, 2026
Bug 1 — shouldDeleteIOUReport never becomes true for individual offline deletes.prepareToCleanUpMoneyRequest decides whether to mark the IOU report as deleted by counting the remaining transactions on the report. It excludes transactions passed in the transactionIDsPendingDeletion array, but the single-delete callers (cleanUpMoneyRequest / getNavigationUrlOnMoneyRequestDelete) never pass that array. Transactions already marked pendingAction: DELETE by a previous queued delete are still counted, so the flag stays false on the second delete.
Because of Bug 1, neither DeleteMoneyRequest call tells the server to also delete the IOU report. When the queue flushes online the server auto-cleans the IOU report after removing the last transaction, and the subsequent DeleteAppReport call hits a report that no longer exists and returns an error.
Bug 2 — deleteAppReport failureData resurrects the deleted report with Onyx.METHOD.SET. On failure it writes the full original report object back into Onyx, re-creating the ghost empty report that the user sees. The sibling failure block also restores reportActionsForReport, which is where the "unexpected error" message on the report actions comes from.
What changes do you think we should make in order to solve the problem?
In prepareToCleanUpMoneyRequest, make shouldDeleteIOUReport exclude transactions that are already marked pendingAction: DELETE, so the second queued offline delete correctly decides to delete the IOU report itself (and the matching report actions). This removes the need for a separate DeleteAppReport round-trip in this flow.
--- a/src/libs/actions/IOU/DeleteMoneyRequest.ts+++ b/src/libs/actions/IOU/DeleteMoneyRequest.ts
// If we are deleting the last transaction on a report, then delete the report too
- const shouldDeleteIOUReport = getReportTransactions(iouReportID).filter((trans) => !transactionIDsPendingDeletion?.includes(trans.transactionID)).length === 1;+ const shouldDeleteIOUReport =+ getReportTransactions(iouReportID).filter(+ (trans) =>+ !transactionIDsPendingDeletion?.includes(trans.transactionID) &&+ trans.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,+ ).length === 1;
Add a checkAndFixConflictingRequest resolver for DELETE_APP_REPORT in RequestConflictUtils.ts: if every non-deleted money-request action on the target report is already covered by a preceding DELETE_MONEY_REQUEST in the persisted queue, the report will be gone server-side before DELETE_APP_REPORT runs, so drop it. This prevents the failing round-trip that triggers Bug 2, and the optimistic data already put the report into the correct "deleted" state.
--- a/src/libs/actions/RequestConflictUtils.ts+++ b/src/libs/actions/RequestConflictUtils.ts+function resolveDeleteAppReportConflict(+ persistedRequests: AnyRequest[],+ parameters: DeleteAppReportParams,+): ConflictActionData {+ const reportID = parameters.reportID;+ const transactionIDs = Object.keys(JSON.parse(parameters.transactionIDToReportActionAndThreadData ?? '{}'));++ const allTransactionsAlreadyQueuedForDelete = transactionIDs.every((transactionID) =>+ persistedRequests.some(+ (request) => request.command === WRITE_COMMANDS.DELETE_MONEY_REQUEST && request.data?.transactionID === transactionID,+ ),+ );++ if (allTransactionsAlreadyQueuedForDelete) {+ // Server will auto-delete the IOU report once the last DeleteMoneyRequest runs,+ // so DeleteAppReport would fail and resurrect the report via its failureData.+ return {conflictAction: {type: 'noAction'}};+ }+ return {conflictAction: {type: 'push'}};+}
In deleteAppReport failureData, stop blindly restoring the full report object with Onyx.METHOD.SET. The correct recovery is to re-attach the pending-delete marker the user can retry on, not to overwrite whatever state Onyx already holds — which is what creates the ghost report when the underlying report no longer exists. Switch the restore to Onyx.METHOD.MERGE of a pendingFields.preview: null + errors patch so that a genuine failure surfaces the error on the existing record without ever re-creating a deleted one.
Register the new resolver so API.write uses it when DELETE_APP_REPORT is enqueued. Wire it through the same mechanism already used for other conflict-resolving WRITE commands.
What alternative solutions did you explore? (Optional)
Only fixing Bug 2 (the failureData restore) without fixing Bug 1 would still leave DELETE_APP_REPORT racing with the server's implicit IOU-report deletion and generate unnecessary failed requests. Only fixing Bug 1 without the conflict resolver would keep the queued DELETE_APP_REPORT around and still resurrect the report via its own failureData. The two fixes together remove both the cause (unnecessary request) and the symptom (bad failure recovery).
⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai.
I tested the MelvinBot proposal and I don’t think it fully solves this issue.
MelvinBot’s approach helps with the later stale DeleteAppReport / ghost-report part, but it does not cover this case:
Create a report with 2 expenses
Go offline
Delete expense A
Delete expense B
At this point, the report should already be treated as deleted and the app should navigate back correctly. But DeleteMoneyRequest still counts transactions already marked with pendingAction: DELETE when computing shouldDeleteIOUReport, so the second delete does not recognize that it is deleting the last visible expense.
Because of that, the app can still enter the wrong intermediate empty-report state, and the later DeleteAppReport handling only cleans up the downstream symptom.
Activity
MelvinBot commentedon Apr 13, 2026
Proposal
What is the root cause of that problem?
When expenses are deleted individually and then the report is deleted while offline, three commands are queued:
DeleteMoneyRequest(A),DeleteMoneyRequest(B),DeleteAppReport. When the app goes online, the SequentialQueue processes them in order. The server may auto-delete the IOU report when the last transaction is removed viaDeleteMoneyRequest(B). ThenDeleteAppReportfails (report already gone server-side), and its failureData restores the full report object back into Onyx viaOnyx.METHOD.SET— creating a ghost empty report.The error message comes from
DeleteMoneyRequest's failureData applyingiou.error.genericDeleteFailureMessageto the report actions.A key contributing factor:
shouldDeleteIOUReportis alwaysfalsefor individual deletes becausegetReportTransactionscounts all transactions including those withpendingAction: DELETE(DeleteMoneyRequest.ts:120). This means neitherDeleteMoneyRequestcall tells the server to clean up the report — the server does it on its own when the last transaction is removed, thenDeleteAppReportfails against an already-deleted resource.What changes do you think we should make in order to solve the problem?
Add a
checkAndFixConflictingRequesthandler toDeleteAppReportthat detects when all transactions on the report have already been deleted by precedingDeleteMoneyRequestcommands in the queue. If the report would already be empty/deleted server-side, remove theDeleteAppReportrequest from the queue entirely (since the server already handled cleanup).Alternatively, update
DeleteAppReport's failureData to not blindly restore the report — instead ofOnyx.METHOD.SETwith the full original report, it should set the report tonullwhen the failure is due to a "not found" response (the report was already cleaned up server-side). This would prevent the ghost report from being recreated in Onyx.What alternative solutions did you explore? (Optional)
Fix
shouldDeleteIOUReportcalculation — filter out transactions withpendingAction: DELETEin the count so the secondDeleteMoneyRequestcorrectly determines it should delete the IOU report. This would preventDeleteAppReportfrom being needed at all, but changes behavior broadly and could have side effects on other flows.Skip
DeleteAppReportclient-side — when callingdeleteAppReport, check if all transactions already havependingAction: DELETEand skip the API call entirely. Simpler but less robust since it only handles this specific ordering.Investigation details
Key code locations:
deleteMoneyRequestoptimistic/failure data:App/src/libs/actions/IOU/DeleteMoneyRequest.ts:632-915deleteAppReportfailure data restores report:App/src/libs/actions/Report/index.ts:5973-5977App/src/libs/actions/OnyxUpdates.ts:35App/src/libs/Network/SequentialQueue.ts:123-263Data flow:
DELETE_MONEY_REQUESTqueued (shouldDeleteIOUReport=false)DELETE_MONEY_REQUESTqueued (shouldDeleteIOUReport=false— transaction A still counted)DELETE_APP_REPORTqueued, failureData captures current report stateDeleteMoneyRequestcalls successfully, auto-cleans IOU reportDeleteAppReport(report gone) → failureDataSETs full report back into OnyxPossibly related: #87065 (restored expense detail preview empty after going back online) and #86710 (Onyx data not synced with server / persisted requests).
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon Apr 13, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (
External)[-]Expense-Deleted report in offline is shown as empty report with unexpected error message[/-][+][$250] Expense-Deleted report in offline is shown as empty report with unexpected error message[/+]melvin-bot commentedon Apr 13, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022043664440522530461
mukhrr commentedon Apr 13, 2026
Proposal
What is the root cause of that problem?
Two cooperating bugs produce the ghost report.
Bug 1 —
shouldDeleteIOUReportnever becomestruefor individual offline deletes.prepareToCleanUpMoneyRequestdecides whether to mark the IOU report as deleted by counting the remaining transactions on the report. It excludes transactions passed in thetransactionIDsPendingDeletionarray, but the single-delete callers (cleanUpMoneyRequest/getNavigationUrlOnMoneyRequestDelete) never pass that array. Transactions already markedpendingAction: DELETEby a previous queued delete are still counted, so the flag staysfalseon the second delete.App/src/libs/actions/IOU/DeleteMoneyRequest.ts
Lines 114 to 120 in 1f51f18
Because of Bug 1, neither
DeleteMoneyRequestcall tells the server to also delete the IOU report. When the queue flushes online the server auto-cleans the IOU report after removing the last transaction, and the subsequentDeleteAppReportcall hits a report that no longer exists and returns an error.Bug 2 —
deleteAppReportfailureData resurrects the deleted report withOnyx.METHOD.SET. On failure it writes the full originalreportobject back into Onyx, re-creating the ghost empty report that the user sees. The sibling failure block also restoresreportActionsForReport, which is where the "unexpected error" message on the report actions comes from.App/src/libs/actions/Report/index.ts
Lines 5966 to 5970 in 1f51f18
App/src/libs/actions/Report/index.ts
Lines 5943 to 5948 in 1f51f18
What changes do you think we should make in order to solve the problem?
prepareToCleanUpMoneyRequest, makeshouldDeleteIOUReportexclude transactions that are already markedpendingAction: DELETE, so the second queued offline delete correctly decides to delete the IOU report itself (and the matching report actions). This removes the need for a separateDeleteAppReportround-trip in this flow.App/src/libs/actions/IOU/DeleteMoneyRequest.ts
Line 120 in 1f51f18
checkAndFixConflictingRequestresolver forDELETE_APP_REPORTinRequestConflictUtils.ts: if every non-deleted money-request action on the target report is already covered by a precedingDELETE_MONEY_REQUESTin the persisted queue, the report will be gone server-side beforeDELETE_APP_REPORTruns, so drop it. This prevents the failing round-trip that triggers Bug 2, and the optimistic data already put the report into the correct "deleted" state.App/src/libs/actions/Report/index.ts
Lines 5650 to 5715 in 1f51f18
deleteAppReportfailureData, stop blindly restoring the fullreportobject withOnyx.METHOD.SET. The correct recovery is to re-attach the pending-delete marker the user can retry on, not to overwrite whatever state Onyx already holds — which is what creates the ghost report when the underlying report no longer exists. Switch the restore toOnyx.METHOD.MERGEof apendingFields.preview: null+errorspatch so that a genuine failure surfaces the error on the existing record without ever re-creating a deleted one.App/src/libs/actions/Report/index.ts
Lines 5966 to 5970 in 1f51f18
API.writeuses it whenDELETE_APP_REPORTis enqueued. Wire it through the same mechanism already used for other conflict-resolving WRITE commands.App/src/libs/actions/Report/index.ts
Line 6047 in 1f51f18
What alternative solutions did you explore? (Optional)
Only fixing Bug 2 (the failureData restore) without fixing Bug 1 would still leave
DELETE_APP_REPORTracing with the server's implicit IOU-report deletion and generate unnecessary failed requests. Only fixing Bug 1 without the conflict resolver would keep the queuedDELETE_APP_REPORTaround and still resurrect the report via its own failureData. The two fixes together remove both the cause (unnecessary request) and the symptom (bad failure recovery).13 remaining items
melvin-bot commentedon Apr 27, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
situchan commentedon Apr 29, 2026
@MelvinBot implement this
MelvinBot commentedon Apr 29, 2026
⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai.
Run details
nabi-ebrahimi commentedon May 1, 2026
Hi @situchan
I tested the MelvinBot proposal and I don’t think it fully solves this issue.
MelvinBot’s approach helps with the later stale
DeleteAppReport/ ghost-report part, but it does not cover this case:At this point, the report should already be treated as deleted and the app should navigate back correctly. But
DeleteMoneyRequeststill counts transactions already marked withpendingAction: DELETEwhen computingshouldDeleteIOUReport, so the second delete does not recognize that it is deleting the last visible expense.Because of that, the app can still enter the wrong intermediate empty-report state, and the later
DeleteAppReporthandling only cleans up the downstream symptom.MelvinBot proposal demo
Screen.Recording.2026-05-01.at.12.22.49.PM.mov
mvtglobally commentedon May 2, 2026
Issue not reproducible during KI retests. (First week)
melvin-bot commentedon May 4, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
melvin-bot commentedon May 4, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
melvin-bot commentedon May 4, 2026
@situchan Eep! 4 days overdue now. Issues have feelings too...
situchan commentedon May 5, 2026
Proposals are in review
mallenexpensify commentedon May 7, 2026
Closing as low value. Comment and tag me if you disagree or think you're due payment. Thx