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 2025-09-26] [$250] Reports - Infinite loading of deleted expense on report preview if deleting several expenses #68601
Prerequisite: Account has at least one workspace available.
Open the staging.new.expensify.com website.
Open any workspace chat.
Create three manual expenses.
Navigate to "Reports" > "Expenses"
Select and delete two of the created expenses.
Return to workspace chat.
Note that report preview shows the remaining expense details and also shows the preview of another expense, with infinite loading in it.
Expected Result:
Expenses deleted from a report, should automatically disappear from report preview and only the remaining ones should be visible.
Actual Result:
When deleting several expenses from a report while on "Reports" section and returning to workspace chat, one of the deleted expenses, still appears on report preview displaying infinite loading.
🚨 Edited by proposal-police: This proposal was edited at 2025-08-25 15:53:44 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Reports - Infinite loading of deleted expense on report preview if deleting several expenses
What is the root cause of that problem?
The deleteMoneyRequestOnSearch function only updated search snapshot loading states but didn't optimistically mark individual transactions as deleted. While the regular deleteMoneyRequest function properly sets pendingAction: DELETE on transactions
The filtering logic in useReportWithTransactionsAndViolations only filters out transactions with pendingAction: DELETE when online. Without the DELETE pending action, deleted transactions remained visible in report previews until the server response arrived (But in this case, there is no data since it is already deleted)
The regular deleteMoneyRequest sets pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE as well as sets transaction violations to null on the transaction immediately
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
NA
What alternative solutions did you explore? (Optional)
NA
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Please re-state the problem that we are trying to solve in this issue.
When deleting multiple expenses from a report in the Reports section and then returning to the workspace chat, one of the deleted expenses still appears in the report preview and shows an infinite loading state.
What is the root cause of that problem?
Deletions performed via the search flow correctly set the corresponding transactions_ entries to null in BE. However, the report preview is driven by reportTransactionsAndViolations, and the derived computation that updates this state after transactions_ changes is flawed:
is not met (we can’t find C in previousTransactions because it was lost when we overwrote the map), so C is not removed from reportTransactionsAndViolations. This stale entry leads to the phantom transaction with infinite loading in the preview.
In short: the logic that updates previousTransactions replaces the entire map, causing loss of historical entries needed to correctly detect deletions across successive compute passes.
What changes do you think we should make in order to solve the problem?
if(transactionsUpdates?.[transactionKey]===undefined){// Find which report currently contains this transactionKey in currentValuefor(const[reportID,bucket]ofObject.entries(reportTransactionsAndViolations)){if(bucket?.transactions&&transactionKeyinbucket.transactions){deletereportTransactionsAndViolations[reportID].transactions[transactionKey];}}}
It checks whether the transaction has been deleted, locates the report that contains it, and then removes the transaction from that report.
changed the title [-]Reports - Infinite loading of deleted expense on report preview if deleting several expenses[/-][+][$250] Reports - Infinite loading of deleted expense on report preview if deleting several expenses[/+]on Aug 17, 2025
[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: N/A
[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:
Regression Test Proposal
Test:
Create 3 expenses in a workspace chat
Open Report > Expenses
Delete 2 of the expenses
Go back to WS chat
Verify there is no extra expense with skeleton on the report preview
Actually, my solution can fixed the issue mentioning in this OP. However, after I open PR, we decided to fix another related issue so we go with @bernhardoj solution since it is more completed.
@jliexpensify May I ask if it makes sense to me to get full payment? Thank you
Activity
melvin-bot commentedon Aug 15, 2025
Triggered auto assignment to @jliexpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.lorretheboy commentedon Aug 15, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-08-25 15:53:44 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Reports - Infinite loading of deleted expense on report preview if deleting several expenses
What is the root cause of that problem?
The deleteMoneyRequestOnSearch function only updated search snapshot loading states but didn't optimistically mark individual transactions as deleted. While the regular deleteMoneyRequest function properly sets pendingAction: DELETE on transactions
The filtering logic in useReportWithTransactionsAndViolations only filters out transactions with pendingAction: DELETE when online. Without the DELETE pending action, deleted transactions remained visible in report previews until the server response arrived (But in this case, there is no data since it is already deleted)
App/src/libs/actions/Search.ts
Lines 482 to 485 in aa57d5c
The reason why it doesn't happen on regular deletion process is that it is already handle the optimistically mark transactions as deleted
App/src/libs/actions/IOU.ts
Line 8159 in 8fc238f
The regular deleteMoneyRequest sets pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE as well as sets transaction violations to null on the transaction immediately
App/src/libs/actions/IOU.ts
Lines 8155 to 8167 in 8fc238f
What changes do you think we should make in order to solve the problem?
Updated the deleteMoneyRequestOnSearch function to optimistically mark transactions as deleted, similar to the regular deletion process
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
NA
What alternative solutions did you explore? (Optional)
NA
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
thelullabyy commentedon Aug 16, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
Deletions performed via the search flow correctly set the corresponding
transactions_entries tonullin BE. However, the report preview is driven byreportTransactionsAndViolations, and the derived computation that updates this state aftertransactions_changes is flawed:App/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Lines 39 to 45 in eb438cf
Walkthrough:
Assume we have three transactions: A, B, C. We delete B and C from the search page.
First computation pass
Source:
App/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Line 12 in eb438cf
transactions:{transactions_A: {...}, transactions_B: undefined}previousTransactions:{transactions_A: {...}, transactions_B: {...}, transactions_C: {...}}transactionsToProcess:BApp/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Line 39 in eb438cf
reportTransactionsAndViolations.Second computation pass
Source:
App/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Line 12 in eb438cf
App/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Line 76 in eb438cf
previousTransactionsis overwritten by the lasttransactionssnapshot:App/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Line 76 in eb438cf
transactions:{transactions_A: {...}, transactions_C: undefined}previousTransactions:{transactions_A: {...}, transactions_B: undefined}transactionsToProcess:CApp/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Line 39 in eb438cf
previousTransactionsbecause it was lost when we overwrote the map), so C is not removed fromreportTransactionsAndViolations. This stale entry leads to the phantom transaction with infinite loading in the preview.In short: the logic that updates
previousTransactionsreplaces the entire map, causing loss of historical entries needed to correctly detect deletions across successive compute passes.What changes do you think we should make in order to solve the problem?
App/src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts
Line 76 in eb438cf
previousTransactionspreserves all known transaction keys and values while incorporating the newest snapshot.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
What alternative solutions did you explore? (Optional)
It checks whether the transaction has been deleted, locates the report that contains it, and then removes the transaction from that report.
[-]Reports - Infinite loading of deleted expense on report preview if deleting several expenses[/-][+][$250] Reports - Infinite loading of deleted expense on report preview if deleting several expenses[/+]melvin-bot commentedon Aug 17, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021957222947228774567
melvin-bot commentedon Aug 17, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (
External)64 remaining items
jjcoffee commentedon Sep 26, 2025
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: https://github.com/Expensify/App/pull/65247/files#r2381349576
[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: N/A
[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:
Regression Test Proposal
Test:
Do we agree 👍 or 👎
melvin-bot commentedon Sep 26, 2025
Payment Summary
Upwork Job
BugZero Checklist (@jliexpensify)
jliexpensify commentedon Sep 28, 2025
Payment Summary
lorretheboy commentedon Sep 29, 2025
Actually, my solution can fixed the issue mentioning in this OP. However, after I open PR, we decided to fix another related issue so we go with @bernhardoj solution since it is more completed.
@jliexpensify May I ask if it makes sense to me to get full payment? Thank you
jliexpensify commentedon Sep 29, 2025
Got it, thanks for the extra context - in this case, since your PR solves the original issue and you did open a PR, that is fine!
jliexpensify commentedon Sep 29, 2025
New job - https://www.upwork.com/jobs/~021972487081327432339
@lorretheboy have invited you
lorretheboy commentedon Sep 29, 2025
Thanks @jliexpensify, I have approved it
jliexpensify commentedon Sep 29, 2025
Paid, job closed.
Payment Summary
bernhardoj commentedon Sep 29, 2025
Requested in ND.
trjExpensify commentedon Sep 29, 2025
approved $250 for @bernhardoj.
trjExpensify commentedon Sep 30, 2025
approved $250 for @jjcoffee