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-12-16] [HOLD for payment 2024-12-11] [$250] [Held requests] Partial paying a report causes the wrong amounts to show in the LHN #48760
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Please re-state the problem that we are trying to solve in this issue.
Approving partly a report with held transaction will show the incorrect amount for the new report that contains all the held transaction.
What is the root cause of that problem?
There are 2 problems. First, when we approve the report, we create the new expense report optimistically that contains all the held transactions, but, we only use the first amount as the report total amount.
Second, even though the optimistic data is incorrect, we receive the correct data from the BE response. However, the LHN last message isn't updated immediately. The LHN shows the total from the expense report and we get the report inside the function instead of connecting the LHN component with the report.
Solving the optimistic data is currently enough for the LHN to show the correct amount. But if we also want to fix the 2nd issue, then we can connect the expense report in OptionRowLHNData.
Then, pass it to SidebarUtils.getOptionData > OptionsListUtils.getLastMessageTextForReport and replace the iouReport here with the new iouReport params.
However, there is a BE issue, specifically the ApproveMoneyRequest API where the response returns the previous iouReportID instead of the new one. For example, let's say the current iouReportID is 1 which has 2 held transactions. After approving it, we optimistically move the 2 held transactions to a new report with an ID of 2 then update iouReportID to 2. But the ApproveMoneyRequest response revert the iouReportID back to 1. If we refresh/reopen the chat report, the OpenReport will return the correct iouReportID, 2. So, we need to fix the BE if we want to apply this solution.
If we don't want to rely on iouReportID, then we can follow the same logic here by taking the last action and extract the iouReportID.
changed the title [-]Partial paying a report causes the wrong amounts to show in the LHN[/-][+][Held requests] Partial paying a report causes the wrong amounts to show in the LHN[/+]on Sep 9, 2024
changed the title [-][Held requests] Partial paying a report causes the wrong amounts to show in the LHN[/-][+][$250] [Held requests] Partial paying a report causes the wrong amounts to show in the LHN[/+]on Sep 9, 2024
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon Sep 7, 2024
Triggered auto assignment to @kevinksullivan (
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 Sep 9, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Approving partly a report with held transaction will show the incorrect amount for the new report that contains all the held transaction.
What is the root cause of that problem?
There are 2 problems. First, when we approve the report, we create the new expense report optimistically that contains all the held transactions, but, we only use the first amount as the report total amount.
App/src/libs/actions/IOU.ts
Lines 6390 to 6394 in 03ec468
Also, we don't optimistically update the approved report total by subtracting the current total with the new expense report total
App/src/libs/actions/IOU.ts
Lines 6943 to 6949 in 03ec468
Second, even though the optimistic data is incorrect, we receive the correct data from the BE response. However, the LHN last message isn't updated immediately. The LHN shows the total from the expense report and we get the report inside the function instead of connecting the LHN component with the report.
App/src/libs/OptionsListUtils.ts
Lines 625 to 626 in 03ec468
And even though we connect all reports inside lhn list,
App/src/components/LHNOptionsList/LHNOptionsList.tsx
Line 35 in 25cdaa9
the OptionRowLHNData is memoized, so it won't re-render if the props are not changed.
What changes do you think we should make in order to solve the problem?
Update the optimistic data to set the correct amount for the new expense report.
App/src/libs/actions/IOU.ts
Line 6394 in 03ec468
We can calculate it from the report total and unheldTotal,
(iouReport.total - iouReport.unheldTotal) * -1,or sum the amount from the individual transaction amount.
holdTransactions.reduce((acc, transaction) => acc + transaction.amount, 0)Then, we need to update the current expense report total too.
App/src/libs/actions/IOU.ts
Lines 6918 to 6922 in 03ec468
App/src/libs/actions/IOU.ts
Lines 6943 to 6949 in 03ec468
Solving the optimistic data is currently enough for the LHN to show the correct amount. But if we also want to fix the 2nd issue, then we can connect the expense report in
OptionRowLHNData.Then, pass it to
SidebarUtils.getOptionData>OptionsListUtils.getLastMessageTextForReportand replace the iouReport here with the new iouReport params.App/src/libs/OptionsListUtils.ts
Lines 625 to 626 in 03ec468
However, there is a BE issue, specifically the ApproveMoneyRequest API where the response returns the previous iouReportID instead of the new one. For example, let's say the current iouReportID is 1 which has 2 held transactions. After approving it, we optimistically move the 2 held transactions to a new report with an ID of 2 then update iouReportID to 2. But the ApproveMoneyRequest response revert the iouReportID back to 1. If we refresh/reopen the chat report, the OpenReport will return the correct iouReportID, 2. So, we need to fix the BE if we want to apply this solution.
If we don't want to rely on iouReportID, then we can follow the same logic here by taking the last action and extract the
iouReportID.App/src/libs/OptionsListUtils.ts
Line 626 in 03ec468
Fortunately, we already get the
iouReportIDhere,App/src/components/LHNOptionsList/LHNOptionsList.tsx
Line 131 in 25cdaa9
so we just need to retrieve the report and pass it down to OptionRowLHNData.
[-]Partial paying a report causes the wrong amounts to show in the LHN[/-][+][Held requests] Partial paying a report causes the wrong amounts to show in the LHN[/+][-][Held requests] Partial paying a report causes the wrong amounts to show in the LHN[/-][+][$250] [Held requests] Partial paying a report causes the wrong amounts to show in the LHN[/+]melvin-bot commentedon Sep 9, 2024
Job added to Upwork: https://www.upwork.com/jobs/~021833144594407206391
melvin-bot commentedon Sep 9, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (
External)114 remaining items
bernhardoj commentedon Dec 13, 2024
Yes, I've been paid $250 before.
melvin-bot commentedon Dec 16, 2024
Payment Summary
Upwork Job
BugZero Checklist (@RachCHopkins)
melvin-bot commentedon Dec 16, 2024
@robertjchen, @s77rt, @RachCHopkins, @bernhardoj Whoops! This issue is 2 days overdue. Let's get this updated quick!
robertjchen commentedon Dec 17, 2024
@RachCHopkins Agreed with the increase due to the efforts involved here 👍
s77rt commentedon Dec 17, 2024
Thank you! Can you please update the payment summary above so the approver sees the correct values
RachCHopkins commentedon Dec 18, 2024
@s77rt summary is up to date now!
bernhardoj commentedon Dec 18, 2024
Thanks!
Requested in ND. (again)
JmillsExpensify commentedon Dec 19, 2024
$500 approved for @s77rt
JmillsExpensify commentedon Dec 19, 2024
Additional $250 approved for @bernhardoj