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
[HOLD for payment 2024-01-09] [$500] IOU - Edited amount for a paid request does not revert to initial amount after closing error message #31622
Version Number: v1.4.1-7 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause-Internal Team Slack conversation: @
Action Performed:
Navigate to staging.new.expensify.com.
[User A] Request money from User B.
[User A] Open IOU details page > Click Amount.
[User B] Pay the request.
[User A] Enter a new amount and save it.
[User A] Close the error message.
Expected Result:
The amount in IOU details page should revert to the original amount after closing the error message.
Actual Result:
The amount in IOU details page does not revert to the original amount after closing the error message. It only reverts after refreshing the app.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]IOU - Edited amount for a paid request does not revert to initial amount after closing error message[/-][+][$500] IOU - Edited amount for a paid request does not revert to initial amount after closing error message[/+]on Nov 21, 2023
Please re-state the problem that we are trying to solve in this issue.
The amount is not reverted when the update is failed.
What is the root cause of that problem?
When we update the amount and get an error, we expect it to revert immediately to the previous value, not actually after pressing the error close button.
In the IOU edit code, we already have a failureData to revert the failed update to the previous amount (or any field) here
The reason behind it is this. In short, when we update a transaction, either its amount, description, or other fields, we add a new field/property to the transaction object called modifiedAmount, modifiedCreated, etc. and if we merge the old transaction object, these new properties won't be removed from the object, so the new test added will fail.
What changes do you think we should make in order to solve the problem?
There are 3 onyx keys that the method is changed to set (transaction, iou report, and chat report). Change all 3 back to merge.
Then, we will handle the revert when fails correctly by merging the new property with null.
If you see the above code, you can notice that for chat report, we only update lastMessageText and lastMessageHtml property and both are existing property that is available optimistically, so nothing to change for chat report. For the iou report though, we update
total
cachedTotal
ownerAccountID (in IOUUtils.updateIOUOwnerAndTotal)
managerID (in IOUUtils.updateIOUOwnerAndTotal)
hasOutstandingIOU (in IOUUtils.updateIOUOwnerAndTotal)
lastMessageText
lastMessageHtml
Both lastMessageText and lastMessageHtml is not created optimistically which I think a bit inconsistent with how we create a normal chat report. So, the solution for iou report is to create lastMessageText and lastMessageHtml value optimistically.
(taken from ReportUtils.buildOptimisticChatReport)
lastMessageHtml: '',
lastMessageText: null,
The solution is pretty long, but I think it's what we should do earlier
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:
[@sobitneupane] 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:
[@sobitneupane] A discussion in #expensify-bugs 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:
[@sobitneupane] Determine if we should create a regression test for this bug.
Yes.
[@sobitneupane] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
Activity
[-]IOU - Edited amount for a paid request does not revert to initial amount after closing error message[/-][+][$500] IOU - Edited amount for a paid request does not revert to initial amount after closing error message[/+]melvin-bot commentedon Nov 21, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01674cdc2bbfceb3e4
melvin-bot commentedon Nov 21, 2023
Triggered auto assignment to @slafortune (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 21, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 21, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (
External)DylanDylann commentedon Nov 21, 2023
bernhardoj commentedon Nov 21, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
The amount is not reverted when the update is failed.
What is the root cause of that problem?
When we update the amount and get an error, we expect it to revert immediately to the previous value, not actually after pressing the error close button.
In the IOU edit code, we already have a
failureDatato revert the failed update to the previous amount (or any field) hereApp/src/libs/actions/IOU.js
Lines 1933 to 1947 in 0cca90a
However, I can see that we always get an error, that is, we can't use Onyx.set after Onyx.merge.

This issue happens after #27609 where we change the (3) onyx method from
mergetoset.App/src/libs/actions/IOU.js
Lines 1944 to 1957 in 0cca90a
The reason behind it is this. In short, when we update a transaction, either its amount, description, or other fields, we add a new field/property to the transaction object called
modifiedAmount,modifiedCreated, etc. and if we merge the old transaction object, these new properties won't be removed from the object, so the new test added will fail.What changes do you think we should make in order to solve the problem?
There are 3 onyx keys that the method is changed to
set(transaction,iou report, andchat report). Change all 3 back tomerge.Then, we will handle the revert when fails correctly by merging the new property with null.
Let's start with
transaction. To know which property is new when we update the transaction, compare the new property from getUpdatedTransaction and buildOptimisticTransaction.Those new properties are:
modifiedCreatedmodifiedAmountmodifiedCurrencymodifiedMerchantmodifiedWaypointspendingFieldsAnd in the failure data, we will do it like this:
Next,
iou reportandchat report.App/src/libs/actions/IOU.js
Lines 1789 to 1822 in 0cca90a
If you see the above code, you can notice that for
chat report, we only updatelastMessageTextandlastMessageHtmlproperty and both are existing property that is available optimistically, so nothing to change forchat report. For theiou reportthough, we updatetotalcachedTotalownerAccountID(inIOUUtils.updateIOUOwnerAndTotal)managerID(inIOUUtils.updateIOUOwnerAndTotal)hasOutstandingIOU(inIOUUtils.updateIOUOwnerAndTotal)lastMessageTextlastMessageHtmlBoth
lastMessageTextandlastMessageHtmlis not created optimistically which I think a bit inconsistent with how we create a normalchat report. So, the solution foriou reportis to createlastMessageTextandlastMessageHtmlvalue optimistically.(taken from
ReportUtils.buildOptimisticChatReport)The solution is pretty long, but I think it's what we should do earlier
melvin-bot commentedon Nov 24, 2023
@slafortune, @sobitneupane Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
53 remaining items
slafortune commentedon Jan 18, 2024
coming back to this Monday.
slafortune commentedon Jan 22, 2024
@sobitneupane will you be able to get this off your plate in the next day or two?
melvin-bot commentedon Jan 30, 2024
@tylerkaraszewski, @slafortune, @sobitneupane, @bernhardoj 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
melvin-bot commentedon Feb 1, 2024
@tylerkaraszewski, @slafortune, @sobitneupane, @bernhardoj Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!
sobitneupane commentedon Feb 1, 2024
I will complete the checklist by EOD.
sobitneupane commentedon Feb 2, 2024
#27609
https://github.com/Expensify/App/pull/27609/files#r1475723305
Yes.
#31622 (comment)
sobitneupane commentedon Feb 2, 2024
Regression Test Proposal
Do we agree 👍 or 👎
slafortune commentedon Feb 2, 2024
JmillsExpensify commentedon Feb 14, 2024
$500 approved for @sobitneupane based on summary above.