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-10-09] [$250] Android - Report - Amount is not updated smoothly after deleting expenses from report. #67641
Submit several manual expenses to it . (At least 5)
Open the report of the just created expenses.
Select between two and three expenses.
Delete the selected expenses.
Note that total amount changes to an incorrect amount for some seconds, before changing to the new correct amount.
Expected Result:
When deleting several expenses from a report, total amount should automatically change the the new correct total amount.
Actual Result:
When deleting several expenses from a report, the total amount changes to an incorrect new amount for some seconds, before changing again to the correct new amount.
// Because of the Expense reports are stored as negative values, we add the total from the amount
constamountDiff=getAmount(transaction,true);
updatedIOUReport.total+=amountDiff;
However, since IOU report total isn't immediately updated, each calls to prepareToCleanUpMoneyRequest gives different total. For example, the current report total is 15, then I delete 2 expenses with amounts of 1 and 5. For the first transaction, the report total will be 13. For the second transaction, the report total will be 14. We expect it to be 9.
What changes do you think we should make in order to solve the problem?
for example, when I delete 3 expenses, the 2nd call of prepareToCleanUpMoneyRequest, transactionIDsPendingDeletion will contain the first expense ID, while the 3rd call of prepareToCleanUpMoneyRequest, transactionIDsPendingDeletion will contain the first and second expense ID.
This will have more smooth result, but we will still see the amount is reducing step by step quickly. It's because we use MERGE and we can use SET to make it faster.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can test calling deleteMoneyRequest multiple times and verify that the report total is updated correctly.
What alternative solutions did you explore? (Optional)
For a more complex solution, we can have a separate function to delete multiple transactions and prepareToCleanUpMoneyRequest but we will still need to iterate over all transactions and call the API and update the others optimistic data.
changed the title [-]Android - Report - Amount is not updated smoothly after deleting expenses from report.[/-][+][$250] Android - Report - Amount is not updated smoothly after deleting expenses from report.[/+]on Aug 1, 2025
and as deleteMoneyRequest is design for a single deleltion it updates the iouReport total by deducting the deleted transaction amount on the iouReport total
// Because of the Expense reports are stored as negative values, we add the total from the amount
constamountDiff=getAmount(transaction,true);
updatedIOUReport.total+=amountDiff;
but the subsequent deleteMoneyRequest calls don't receive the updated iouReport value as the iteratee calls occur too quick before the previous onyx update on the iou report takes effect.
What changes do you think we should make in order to solve the problem?
We can pass all selecteTransactionIDs to deleteMoneyRequest here
But alternatively we can progressively update the iou report diff by deducting only the transactionPendingDelete transactions amount and the current deleted transaction
we update the iouReport total if the transaction to be deleted has the same currency as the iouReport but in our case of bulk deletion we should only update the iouReport total if all the deleted transactions have the same currency as the iouReport as we don't have exchange rate data in FE. We should update to
This will avoid continous reducing total value on slower platform as Android by following the method proposed in the above proposal.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can test delelteMoneyRequest handles bulk deletion by passing multiple transactions as selectedTransactionIDs and asserting that the iouReport will be calculated according to all selecteTransactionIDs
What alternative solutions did you explore? (Optional)
As discussed here the current bulk deletion method of calling delete iterating on selectedTransactions has many side effects and the ideal solution if BE change can be made is to add a new bulk deletion API like DELETE_MONEY_REQUEST_ON_SEARCH which handle buld deletion and create a new function in the FE which updates the optimisticData needed for buld deletion, we can re-implement deleteMoneyRequest function by adapting it for bulk deletion.
Thanks for all your proposals. I like @bernhardoj's proposal. I think the amount should be reflected in the processed transactions. It doesn't make sense if the total value is updated while the transactions are not processed, so it can cause confusion
Activity
melvin-bot commentedon Aug 1, 2025
Triggered auto assignment to @Christinadobrzyn (
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.bernhardoj commentedon Aug 1, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Amount is not updated smoothly when deleting multiple expenses.
What is the root cause of that problem?
When we delete multiple expenses, we iterate over it and call
deleteMoneyRequestfor each expense.App/src/hooks/useSelectedTransactionsActions.ts
Lines 88 to 95 in 1dfb9cb
In
deleteMoneyRequest, specifically inprepareToCleanUpMoneyRequest, we update the IOU report total with the transaction/expense amount.App/src/libs/actions/IOU.ts
Lines 7668 to 7674 in 1dfb9cb
However, since IOU report total isn't immediately updated, each calls to
prepareToCleanUpMoneyRequestgives different total. For example, the current report total is 15, then I delete 2 expenses with amounts of 1 and 5. For the first transaction, the report total will be 13. For the second transaction, the report total will be 14. We expect it to be 9.What changes do you think we should make in order to solve the problem?
The simplest solution is,
first, we have a list of pending transaction IDs
App/src/libs/actions/IOU.ts
Line 7613 in 1dfb9cb
for example, when I delete 3 expenses, the 2nd call of
prepareToCleanUpMoneyRequest,transactionIDsPendingDeletionwill contain the first expense ID, while the 3rd call ofprepareToCleanUpMoneyRequest,transactionIDsPendingDeletionwill contain the first and second expense ID.We get the transaction list from the IDs.
Then, we calculate all the pending transaction amount and add it to the
amountDiff.App/src/libs/actions/IOU.ts
Lines 7668 to 7673 in 1dfb9cb
(we can do the same for IOU report)
App/src/libs/actions/IOU.ts
Lines 7691 to 7694 in 1dfb9cb
This will have more smooth result, but we will still see the amount is reducing step by step quickly. It's because we use MERGE and we can use SET to make it faster.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can test calling
deleteMoneyRequestmultiple times and verify that the report total is updated correctly.What alternative solutions did you explore? (Optional)
For a more complex solution, we can have a separate function to delete multiple transactions and
prepareToCleanUpMoneyRequestbut we will still need to iterate over all transactions and call the API and update the others optimistic data.melvin-bot commentedon Aug 1, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021951306802216159736
[-]Android - Report - Amount is not updated smoothly after deleting expenses from report.[/-][+][$250] Android - Report - Amount is not updated smoothly after deleting expenses from report.[/+]melvin-bot commentedon Aug 1, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (
External)FitseTLT commentedon Aug 1, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-08-01 22:36:37 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Android - Report - Amount is not updated smoothly after deleting expenses from report.
What is the root cause of that problem?
We do bulk delete by iterating on the selected trasactions and calling deleteMoneyRequest
App/src/hooks/useSelectedTransactionsActions.ts
Lines 88 to 95 in 1dfb9cb
and as deleteMoneyRequest is design for a single deleltion it updates the iouReport total by deducting the deleted transaction amount on the iouReport total
App/src/libs/actions/IOU.ts
Lines 7668 to 7674 in 1dfb9cb
but the subsequent deleteMoneyRequest calls don't receive the updated iouReport value as the iteratee calls occur too quick before the previous onyx update on the iou report takes effect.
What changes do you think we should make in order to solve the problem?
We can pass all selecteTransactionIDs to deleteMoneyRequest here
App/src/hooks/useSelectedTransactionsActions.ts
Line 93 in 1dfb9cb
and when calculating iouReport total we will determine the diff by suming all selectedTransactionIDs (the whole list of transactions to be deleted.
App/src/libs/actions/IOU.ts
Line 7673 in 1dfb9cb
But alternatively we can progressively update the iou report diff by deducting only the transactionPendingDelete transactions amount and the current deleted transaction
And to avoid a visible effect of the total reducing continously we can update the iou Report via
SEThere spreadingiouREportandupdatedIOUReportApp/src/libs/actions/IOU.ts
Lines 8066 to 8069 in d5ce4e8
Note: another thing we should consider is that here
App/src/libs/actions/IOU.ts
Line 7671 in 1dfb9cb
we update the iouReport total if the transaction to be deleted has the same currency as the iouReport but in our case of bulk deletion we should only update the iouReport total if all the deleted transactions have the same currency as the iouReport as we don't have exchange rate data in FE. We should update to
We will do the same for iou reports here
App/src/libs/actions/IOU.ts
Line 7694 in 1dfb9cb
This will avoid continous reducing total value on slower platform as Android by following the method proposed in the above proposal.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can test delelteMoneyRequest handles bulk deletion by passing multiple transactions as selectedTransactionIDs and asserting that the iouReport will be calculated according to all selecteTransactionIDs
What alternative solutions did you explore? (Optional)
As discussed here the current bulk deletion method of calling delete iterating on selectedTransactions has many side effects and the ideal solution if BE change can be made is to add a new bulk deletion API like
DELETE_MONEY_REQUEST_ON_SEARCHwhich handle buld deletion and create a new function in the FE which updates the optimisticData needed for buld deletion, we can re-implement deleteMoneyRequest function by adapting it for bulk deletion.dukenv0307 commentedon Aug 2, 2025
Thanks for all your proposals. I like @bernhardoj's proposal. I think the amount should be reflected in the processed transactions. It doesn't make sense if the total value is updated while the transactions are not processed, so it can cause confusion
🎀👀🎀 C+ reviewed
54 remaining items
dukenv0307 commentedon Oct 9, 2025
Yeah @FitseTLT, @Christinadobrzyn I think another $250 for me and @FitseTLT for fixing another bug
Christinadobrzyn commentedon Oct 9, 2025
Thanks everyone! @mollfpr let me know what you think of a bonus of $250 for this #68484 (comment) for @dukenv0307 and @FitseTLT
Christinadobrzyn commentedon Oct 10, 2025
Nudged @mollfpr for a review of the bonus
mollfpr commentedon Oct 11, 2025
Apologies for the delay 🙏
I’m fine with the bonus, weighing the bug fixed is essential for the pending transaction.
melvin-bot commentedon Oct 13, 2025
@Christinadobrzyn Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Oct 13, 2025
@Christinadobrzyn Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Christinadobrzyn commentedon Oct 14, 2025
Thanks for confirming @mollfpr!
Payment summary here - #67641 (comment)
Please reach out with any questions otherwise @bernhardoj and @dukenv0307 please request payment via ND.
bernhardoj commentedon Oct 15, 2025
Requested in ND.
garrettmknight commentedon Oct 17, 2025
$100 approved for @bernhardoj
trjExpensify commentedon Oct 21, 2025
Approved $500 for @dukenv0307
garrettmknight commentedon Oct 24, 2025
$500 approved for @dukenv0307