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] QAB - Negative amount briefly displayed when Pay someone #44914
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Version Number: 9.0.4-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail:https://expensify.testrail.io/index.php?/cases/view/2990372 Issue reported by: Applause - Internal Team
Action Performed:
Precondition: user did 'Pay someone' to individual chat
Click FAB
Click QAB > Pay someone
Input amount
Click Pay elsewhere
Expected Result:
User navigated to chat with person he payed. Expense preview displays amount
Actual Result:
User navigated to chat with person he payed. Expense preview briefly displays negative amount (occasionally negative amount may stay)
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Please re-state the problem that we are trying to solve in this issue.
Negative amount is shown on the report preview when pay someone.
What is the root cause of that problem?
The pay amount logic is, if there is a total amount from the IOU report object, then we use that amount, otherwise, we take the amount from the report preview message.
// If iouReport is not available, get amount from the action message (Ex: "Domain20821's Workspace owes $33.00" or "paid ₫60" or "paid -₫60 elsewhere")
In the OP video, we can see the amount changes from
UAH xx -> ₴ xx -> -UAH xx
The reason it shows a negative amount is that the IOU report total is 0, so it takes the amount from the report preview message which is negative. If we see some logic related to the money request amount, we take the abs amount if it's an IOU report, which we don't do here.
But, if we look into the onyx storage, the IOU report actually has a non-zero total, but the data isn't reflected in the report preview component. So, the report preview component holds the old data. It's the withOnyx bug where it doesn't give the most up-to-date data when there are multiple merges happening within a short span of time. It's similar to this issue where the policy data is undefined because activeWorkspaceID is initially undefined but then is updated when the nav state changes, but the policy data stays undefined.
What changes do you think we should make in order to solve the problem?
As withOnyx is officially deprecated, we can just replace it with useOnyx for the ReportPreview component which doesn't have the bug. This will make the component always stay up-to-date.
However, we still have one problem, that is the amount changing. After we replace it with useOnyx, the amount will change from
UAH xx -> ₴ xx -> -UAH xx -> UAH xx
The first amount is the optimistic amount. Then, after the send money request is completed, the send money API response returns multiple Onyx merge requests. The first request merges the IOU report data which has a total data of 0. This overwrites the optimistic total.
Also, notice that the statusNum is 1 which is SUBMITTED instead of 4 (REIMBURSED). This makes the isSettled state becomes false.
Because the total is 0, it will get the amount from the report preview message, but the message from the BE response uses the currency symbol (₴) instead of the currency code (UAH). (the 2nd amount shown)
The last few merge requests from the API response contain the correct data. (the 3rd (the correct message) and then 4th (the correct iou report total) amount is shown)
This needs a BE fix.
Additionally, we can make sure the amount is never be in negative by making it absolute for IOU report,
changed the title [-]QAB - Negative amount briefly displayed when Pay someone[/-][+][$250] QAB - Negative amount briefly displayed when Pay someone[/+]on Jul 10, 2024
I was unable to reproduce (v9.0.24-1). I believe this issue was being caused by some conflict in the server response, which is why there were times when we were able to reproduce it and others not. I didn't find anything strange about it in FE.
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
melvin-bot commentedon Jul 5, 2024
Triggered auto assignment to @JmillsExpensify (
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 Jul 6, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Negative amount is shown on the report preview when pay someone.
What is the root cause of that problem?
The pay amount logic is, if there is a total amount from the IOU report object, then we use that amount, otherwise, we take the amount from the report preview message.
App/src/components/ReportActionItem/ReportPreview.tsx
Lines 206 to 232 in c5eafd3
In the OP video, we can see the amount changes from
UAH xx -> ₴ xx -> -UAH xx
The reason it shows a negative amount is that the IOU report total is 0, so it takes the amount from the report preview message which is negative. If we see some logic related to the money request amount, we take the abs amount if it's an IOU report, which we don't do here.
App/src/libs/ReportUtils.ts
Lines 2408 to 2412 in c5eafd3
But, if we look into the onyx storage, the IOU report actually has a non-zero total, but the data isn't reflected in the report preview component. So, the report preview component holds the old data. It's the withOnyx bug where it doesn't give the most up-to-date data when there are multiple merges happening within a short span of time. It's similar to this issue where the policy data is undefined because
activeWorkspaceIDis initially undefined but then is updated when the nav state changes, but the policy data stays undefined.What changes do you think we should make in order to solve the problem?
As
withOnyxis officially deprecated, we can just replace it withuseOnyxfor theReportPreviewcomponent which doesn't have the bug. This will make the component always stay up-to-date.However, we still have one problem, that is the amount changing. After we replace it with
useOnyx, the amount will change fromUAH xx -> ₴ xx -> -UAH xx -> UAH xx
The first amount is the optimistic amount. Then, after the send money request is completed, the send money API response returns multiple Onyx merge requests. The first request merges the IOU report data which has a

totaldata of 0. This overwrites the optimistic total.Also, notice that the
statusNumis 1 which is SUBMITTED instead of 4 (REIMBURSED). This makes theisSettledstate becomes false.Because the
totalis 0, it will get the amount from the report preview message, but the message from the BE response uses the currency symbol (₴) instead of the currency code (UAH). (the 2nd amount shown)The last few merge requests from the API response contain the correct data. (the 3rd (the correct message) and then 4th (the correct iou report total) amount is shown)
This needs a BE fix.
Additionally, we can make sure the amount is never be in negative by making it absolute for IOU report,
App/src/components/ReportActionItem/ReportPreview.tsx
Lines 218 to 230 in c5eafd3
just like we did here.
App/src/libs/ReportUtils.ts
Line 2412 in c5eafd3
melvin-bot commentedon Jul 8, 2024
@JmillsExpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Jul 10, 2024
Job added to Upwork: https://www.upwork.com/jobs/~01ee0d66d57ed7a8d9
[-]QAB - Negative amount briefly displayed when Pay someone[/-][+][$250] QAB - Negative amount briefly displayed when Pay someone[/+]melvin-bot commentedon Jul 10, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @brunovjk (
External)JmillsExpensify commentedon Jul 10, 2024
I'll add the external label. If the solution is straightforward we can fix it.
35 remaining items
melvin-bot commentedon Aug 14, 2024
📣 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 Aug 19, 2024
@JmillsExpensify, @brunovjk Eep! 4 days overdue now. Issues have feelings too...
brunovjk commentedon Aug 20, 2024
melvin-bot commentedon Aug 21, 2024
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
mvtglobally commentedon Aug 23, 2024
Issue not reproducible during KI retests. (Third week)
melvin-bot commentedon Aug 23, 2024
@JmillsExpensify, @brunovjk Whoops! This issue is 2 days overdue. Let's get this updated quick!
brunovjk commentedon Aug 24, 2024
I was unable to reproduce (v9.0.24-1). I believe this issue was being caused by some conflict in the server response, which is why there were times when we were able to reproduce it and others not. I didn't find anything strange about it in FE.
cc: @JmillsExpensify
brunovjk commentedon Aug 27, 2024
@JmillsExpensify Do you think we can get someone else to reproduce and confirm that the issue still exists? Thank you.
JmillsExpensify commentedon Aug 28, 2024
Let's just close. It's not reproducible for several QA runs. Thanks for reaching out via Slack!