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
[C+ Checklist Needs Completion] [$500] Money Request - Deleted IOU in offline mode appears when User switch to online #26511
The request should be deleted and the message should be still grayed out in offline mode.
When user switch to online mode the request should remain deleted
Actual Result:
When user delete the request in offline mode the request should be grayed out, in this case the request disappear
Deleted IOU in offline mode appears when User switch to online
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android / native
Android / Chrome
iOS / native
iOS / Safari
Windows / Chrome
MacOS / Desktop
Version Number: 1.3.61-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail:
Please re-state the problem that we are trying to solve in this issue.
Problem: When Offline, deleting the last Money Request (without any comments) in IOU Report removes Report Preview from parent Chat Report Steps:
1 Go Offline
2 Add Money Request in Chat Report.
3 Go to IOU Report for the Money Request
4 Delete Money Request
Actual Result: When offline, Report Preview is removed from parent Chat Report Expected Result: When offline, Report Preview should be shown. Further, Money Request preview in IOU Report should also be shown with striked-out amount.
Issue-1 Video1-mr-offline-removed.mp4
What is the root cause of that problem?
Deletion of the money request happens in deleteMoneyRequest function here. Here, we are setting IOUReport and Report Preview action to null as we can see here and here because of which Report Preview action and IOU Report are removed. This is the root cause.
What changes do you think we should make in order to solve the problem?
The following changes can be done to solve this problem.
First thing to do is not to set IOUReport and reportPreviewAction to null. Instead, let us reuse the existing object until API response comes back. For this, we can set these variables to the existing objects.
Secondly, for cases where the IOU report will be deleted, we can set the pendingAction to DELETE and UPDATE for other cases. We can update the ReportPreviewAction with these values so that Report Preview action will remain shown in offline mode. We can make the changes like this here.
let updatedIOUReport = {...iouReport};
let updatedReportPreviewAction = {...reportPreviewAction};
updatedReportPreviewAction.pendingAction = shouldDeleteIOUReport ? CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE : CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE;
Further, for success API response, we need to reset the IOU Report and Report Preview Action accordingly like shown below. We can make the changes here
a) For reportPreviewAction, we can set it to null if IOU report is deleted. Otherwise, we can reset the pendingAction to indicate that action is completed.
b) For IOU Report, we can set it to null if it has been deleted.
To support offline support, we also need to update the IOU Report and Report Preview action. So, we can update them by removing the following line here
if (!shouldDeleteIOUReport) {
Also, to keep showing money request preview in IOU Report, we should prevent resetting of the money request action. We can make the changes to the code here like this
Further, we can remove the code here as that would reset the iouReportID. This would fail the offline scenario. This is anyways going to be reset by API response.
What alternative solutions did you explore? (Optional)
Issue 2:
Please re-state the problem that we are trying to solve in this issue.
Problem: When Offline, Report Preview shows TBD on deletion of last Money Request in IOU Report with comments Steps:
1 Go Offline
2 Add Money Request in Chat Report
3 Go to IOU Report for Money Request
4 Add a message in IOU Report
5 Delete the only Money Request in IOU Report (created in Step 2)
6 Go to parent Chat Report Actual Result: TBD is shown in Report Preview in Chat Report Expected Result: Amount 0 should be shown in Report Preview in Chat Report
Issue-2 Video2-mr-tbd-with-msg.mp4
What is the root cause of that problem?
TBD is shown because hasOnlyDistanceRequestTransactionshere returns true even for cases where there are no transactions. In our case here, since all money requests are deleted, there will be no transactions. So, the root cause is that hasOnlyDistanceRequestTransactions is faulty for cases with no transactions.
What changes do you think we should make in order to solve the problem?
To solve the problem, we need to additionally handle the case when there are no transactions in the IOU Report. We can check for the size of the transactions’ list and return false if it is empty. If not empty, we go ahead and iterate through each to find out if it is a distance request.
Solution 2:
We can also revise the existing implementation and migrate to typescript as follows. We can add this function in TransactionUtils.ts and call this within hasOnlyDistanceRequestTransactionshere
What alternative solutions did you explore? (Optional)
Issue 3:
Please re-state the problem that we are trying to solve in this issue.
Problem : When Offline, Report Preview does not update amount when a new Money Request is added Steps:
1 Go Offline
2 Add Money Request in 1:1 DM Chat Report (Note: Chat Report is not a Workspace Chat)
3 Go to IOU Report for Money Request
4 Add a message in IOU Report
5 Delete the only Money Request in IOU Report (created in Step 2)
6 Go to parent Chat Report.
7 Go to IOU Report again by clicking on the Report Preview and add a new Money Request
8 Go to parent Chat Report and review Report Preview amount. Actual Result: Report Preview amount is not updated with money request amount of step 7 Expected Result: Report Preview amount should be updated with money request amount of step 7
Issue-3 Video 3-amount-not-updated.mp4
What is the root cause of that problem?
Here, we update the total amount for Report Preview of IOU Report and Expense Report. While the Expense Report total is updated properly, the IOU Report total is updated using updateIOUOwnerAndTotalhere. However, the amount will only be updated if the current total amount is not 0 as seen here. This is faulty as there can be cases where total amount is 0 and the IOU Report still exists due to presence of normal comments(messages). So, checking if total amount is 0 is the root cause of this issue.
What changes do you think we should make in order to solve the problem?
To solve the problem, we need to allow updation of total even when the all the money requests are deleted.
We can solve this by updating the following condition here which will keep the logic consistent and also prevent any other bugs.
if (typeof iouReportUpdate.total !== 'undefined') {
What alternative solutions did you explore? (Optional)
Alternatively, we can also remove the following condition and resolve the problem.
- if (iouReportUpdate.total) {
Issue 4:
Please re-state the problem that we are trying to solve in this issue.
Problem : When Offline, IOU Report page shows blank on navigating back from parent Chat Report via click on Reply link Steps:
1 Go Offline
2 Add Money Request in Chat Report
3 Go to IOU Report for Money Request
4 Add a message in IOU Report
6 Go to parent Chat Report. Verify that the Report Preview shows with Reply Count.
7 Click on Reply link to go to IOU Report Actual Result: IOU Report screen is shown as blank Expected Result: IOU Report Screen should be correctly shown
Issue-4 Video4-blank-iou-report-1.mp4
What is the root cause of that problem?
When we click on Report Preview, we use the information of iouReportID as shown here. However, iouReportID is obtained from linkedReportID within Report Preview action as mentioned here. Since linkedReportID is optimistically added to the Report Preview action here IOU Report shows up on click of Report Preview even in offline scenaio.
Now, when we click on Reply link in Report Preview, we use the information of childReportID in Report Preview’s action as shown here for showing the IOU Report screen. However, when we optimistically create the Report Preview’s action for the IOU Report here, we do not assign the childReportID. If this was online, the BE would update the childReportID due to which this this issue will not occur in online scenario. But, since the childReportID was not optimistically set, the problem occurs in offline scenario. This is the root cause of the problem.
What changes do you think we should make in order to solve the problem?
When we optimistically create the Report Preview action, we should also set childReportIDhere like this:
childReportID: iouReport.reportID,
In addition, we can leverage the existing originalMessage.linkedReportID to pass IOU Report ID as follows
What alternative solutions did you explore? (Optional)
Alternatively, we can also pass the linkedReportID instead of childReportID to the ReportActionItemThread and make this work. But, since we anyway have to optimistically add the childReportID to the Report Preview action, we can set childReportID and solve the problem.
changed the title [-]Money Request - Deleted IOU in offline mode appears when User switch to online[/-][+][$500] Money Request - Deleted IOU in offline mode appears when User switch to online[/+]on Sep 4, 2023
That issue was considered a separate issue. Also, we have not discussed any reward there yet.
So, I have included that too in my comment here.
If we want to consider that issue separately, then we have solved 4 issues as part of this issue.
I think @blimpich can take a call on how to consider this issue.
Regarding the issue itself, I am not sure if we can consider it as a regression because offline support for money requests was introduced only here. It is sort of a new feature.
Also, the fix for this issue involved code changes due to recent changes in a separate unrelated PR here whereas the code changes as part of this issue stayed the same. @fedirjh , @blimpich, please correct me if I am wrong here.
Okay. I mean what is the proposed bounty increase in the first place? Someone suggested we raise it at some point in the past but I don't think we ever got to a number.
Can anyone articulate the amount of work that went into this compared to a "typical" issue?
Lets do $1000 for the whole thing, including #34263, and not apply any penalty to this issue. @rojiphil I really appreciate the attention to detail and professionalism, and I agree this deserves more of a reward than a normal issue 🙂. And in the future we can make sure we increase the bounty before you put up your PR, so that you can know what you're going to get paid before working on an issue.
changed the title [-][HOLD for payment 2024-01-18] [$500] Money Request - Deleted IOU in offline mode appears when User switch to online[/-][+][C+ Checklist Needs Completion] [$500] Money Request - Deleted IOU in offline mode appears when User switch to online[/+]on Jan 18, 2024
Link to the PR: This is a feature, the offline feedback was not implemented for this use case.
Link to comment: N/A
Link to discussion: N/A
Determine if we should create a regression test for this bug: Yes
1. Go Offline
2. Add Money Request in Chat Report (DM)
3. Navigate to IOU Report for that Money Request
4. Delete the money request
5. Verify that the Money Request preview in the IOU Report is displayed with striked-out style
6. Navigate to main report
7. Verify the IOU report Preview is displayed with amount 0
8. Add another Money Request in Chat Report
9. Verify that a new IOU report is created
10. Navifgate to the new IOU report
11. Add a new Money Request inside it
12. Verify that the total amount is updated to match the correct amount
13. Send some messages inside the IOU report
14. Navigate back to the main report
15. Verify that the new IOU report is displayed with the correct amount and has the correct reply count
16. Press on the thread reply count
17. Verify that It navigates you to the correct IOU report
Activity
melvin-bot commentedon Sep 1, 2023
Triggered auto assignment to @greg-schroeder (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Sep 1, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)rojiphil commentedon Sep 2, 2023
rojiphil commentedon Sep 4, 2023
Proposal
Issue 1:
Please re-state the problem that we are trying to solve in this issue.
Problem: When Offline, deleting the last Money Request (without any comments) in IOU Report removes Report Preview from parent Chat Report
Steps:
1 Go Offline
2 Add Money Request in Chat Report.
3 Go to IOU Report for the Money Request
4 Delete Money Request
Actual Result: When offline, Report Preview is removed from parent Chat Report
Expected Result: When offline, Report Preview should be shown. Further, Money Request preview in IOU Report should also be shown with striked-out amount.
Issue-1 Video
1-mr-offline-removed.mp4
What is the root cause of that problem?
Deletion of the money request happens in
deleteMoneyRequestfunction here. Here, we are setting IOUReport and Report Preview action to null as we can see here and here because of which Report Preview action and IOU Report are removed. This is the root cause.What changes do you think we should make in order to solve the problem?
The following changes can be done to solve this problem.
IOUReportandreportPreviewActionto null. Instead, let us reuse the existing object until API response comes back. For this, we can set these variables to the existing objects.Secondly, for cases where the IOU report will be deleted, we can set the pendingAction to DELETE and UPDATE for other cases. We can update the ReportPreviewAction with these values so that Report Preview action will remain shown in offline mode. We can make the changes like this here.
a) For reportPreviewAction, we can set it to null if IOU report is deleted. Otherwise, we can reset the
pendingActionto indicate that action is completed.b) For IOU Report, we can set it to null if it has been deleted.
if (!shouldDeleteIOUReport) {Also, to keep showing money request preview in IOU Report, we should prevent resetting of the money request action. We can make the changes to the code here like this
Further, we can remove the code here as that would reset the
iouReportID. This would fail the offline scenario. This is anyways going to be reset by API response.What alternative solutions did you explore? (Optional)
Issue 2:
Please re-state the problem that we are trying to solve in this issue.
Problem: When Offline, Report Preview shows TBD on deletion of last Money Request in IOU Report with comments
Steps:
1 Go Offline
2 Add Money Request in Chat Report
3 Go to IOU Report for Money Request
4 Add a message in IOU Report
5 Delete the only Money Request in IOU Report (created in Step 2)
6 Go to parent Chat Report
Actual Result: TBD is shown in Report Preview in Chat Report
Expected Result: Amount 0 should be shown in Report Preview in Chat Report
Issue-2 Video
2-mr-tbd-with-msg.mp4
What is the root cause of that problem?
TBD is shown because
hasOnlyDistanceRequestTransactionshere returns true even for cases where there are no transactions. In our case here, since all money requests are deleted, there will be no transactions. So, the root cause is thathasOnlyDistanceRequestTransactionsis faulty for cases with no transactions.What changes do you think we should make in order to solve the problem?
To solve the problem, we need to additionally handle the case when there are no transactions in the IOU Report. We can check for the size of the transactions’ list and return false if it is empty. If not empty, we go ahead and iterate through each to find out if it is a distance request.
Solution 1:
We can solve like this here:
return _.size(allTransactions) > 0 ? _.all(allTransactions, (transaction) => TransactionUtils.isDistanceRequest(transaction)) : false;Solution 2:
We can also revise the existing implementation and migrate to typescript as follows. We can add this function in
TransactionUtils.tsand call this withinhasOnlyDistanceRequestTransactionshereWhat alternative solutions did you explore? (Optional)
Issue 3:
Please re-state the problem that we are trying to solve in this issue.
Problem : When Offline, Report Preview does not update amount when a new Money Request is added
Steps:
1 Go Offline
2 Add Money Request in 1:1 DM Chat Report (Note: Chat Report is not a Workspace Chat)
3 Go to IOU Report for Money Request
4 Add a message in IOU Report
5 Delete the only Money Request in IOU Report (created in Step 2)
6 Go to parent Chat Report.
7 Go to IOU Report again by clicking on the Report Preview and add a new Money Request
8 Go to parent Chat Report and review Report Preview amount.
Actual Result: Report Preview amount is not updated with money request amount of step 7
Expected Result: Report Preview amount should be updated with money request amount of step 7
Issue-3 Video
3-amount-not-updated.mp4
What is the root cause of that problem?
Here, we update the total amount for Report Preview of IOU Report and Expense Report. While the Expense Report total is updated properly, the IOU Report total is updated using
updateIOUOwnerAndTotalhere. However, the amount will only be updated if the current total amount is not 0 as seen here. This is faulty as there can be cases where total amount is 0 and the IOU Report still exists due to presence of normal comments(messages). So, checking if total amount is 0 is the root cause of this issue.What changes do you think we should make in order to solve the problem?
To solve the problem, we need to allow updation of total even when the all the money requests are deleted.
We can solve this by updating the following condition here which will keep the logic consistent and also prevent any other bugs.
if (typeof iouReportUpdate.total !== 'undefined') {What alternative solutions did you explore? (Optional)
Alternatively, we can also remove the following condition and resolve the problem.
- if (iouReportUpdate.total) {Issue 4:
Please re-state the problem that we are trying to solve in this issue.
Problem : When Offline, IOU Report page shows blank on navigating back from parent Chat Report via click on Reply link
Steps:
1 Go Offline
2 Add Money Request in Chat Report
3 Go to IOU Report for Money Request
4 Add a message in IOU Report
6 Go to parent Chat Report. Verify that the Report Preview shows with Reply Count.
7 Click on Reply link to go to IOU Report
Actual Result: IOU Report screen is shown as blank
Expected Result: IOU Report Screen should be correctly shown
Issue-4 Video
4-blank-iou-report-1.mp4
What is the root cause of that problem?
When we click on
Report Preview, we use the information ofiouReportIDas shown here. However,iouReportIDis obtained fromlinkedReportIDwithin Report Preview action as mentioned here. SincelinkedReportIDis optimistically added to the Report Preview action here IOU Report shows up on click of Report Preview even in offline scenaio.Now, when we click on
Replylink in Report Preview, we use the information ofchildReportIDin Report Preview’s action as shown here for showing the IOU Report screen. However, when we optimistically create the Report Preview’s action for the IOU Report here, we do not assign thechildReportID. If this was online, the BE would update thechildReportIDdue to which this this issue will not occur in online scenario. But, since thechildReportIDwas not optimistically set, the problem occurs in offline scenario. This is the root cause of the problem.What changes do you think we should make in order to solve the problem?
When we optimistically create the Report Preview action, we should also set
childReportIDhere like this:childReportID: iouReport.reportID,In addition, we can leverage the existing
originalMessage.linkedReportIDto pass IOU Report ID as followschildReportID={${props.action.childReportID || props.action.originalMessage.linkedReportID}}What alternative solutions did you explore? (Optional)
Alternatively, we can also pass the
linkedReportIDinstead ofchildReportIDto theReportActionItemThreadand make this work. But, since we anyway have to optimistically add thechildReportIDto the Report Preview action, we can setchildReportIDand solve the problem.greg-schroeder commentedon Sep 4, 2023
Reviewing
[-]Money Request - Deleted IOU in offline mode appears when User switch to online[/-][+][$500] Money Request - Deleted IOU in offline mode appears when User switch to online[/+]melvin-bot commentedon Sep 4, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01bb43036fdffd3721
152 remaining items
situchan commentedon Jan 18, 2024
Seems like they're going to get reward for fixing #34263 as separate issue.
So neither increasing bounty nor applying penalty makes sense here.
rojiphil commentedon Jan 18, 2024
@greg-schroeder
That issue was considered a separate issue. Also, we have not discussed any reward there yet.
So, I have included that too in my comment here.
If we want to consider that issue separately, then we have solved 4 issues as part of this issue.
I think @blimpich can take a call on how to consider this issue.
Regarding the issue itself, I am not sure if we can consider it as a regression because offline support for money requests was introduced only here. It is sort of a new feature.
Also, the fix for this issue involved code changes due to recent changes in a separate unrelated PR here whereas the code changes as part of this issue stayed the same.
@fedirjh , @blimpich, please correct me if I am wrong here.
greg-schroeder commentedon Jan 18, 2024
Okay. I mean what is the proposed bounty increase in the first place? Someone suggested we raise it at some point in the past but I don't think we ever got to a number.
Can anyone articulate the amount of work that went into this compared to a "typical" issue?
blimpich commentedon Jan 18, 2024
Lets do $1000 for the whole thing, including #34263, and not apply any penalty to this issue. @rojiphil I really appreciate the attention to detail and professionalism, and I agree this deserves more of a reward than a normal issue 🙂. And in the future we can make sure we increase the bounty before you put up your PR, so that you can know what you're going to get paid before working on an issue.
greg-schroeder commentedon Jan 18, 2024
Sounds good to me, I'll adjust the offers.
greg-schroeder commentedon Jan 18, 2024
Paid $1k to both C and C+
greg-schroeder commentedon Jan 18, 2024
@fedirjh just need to complete the checklist above and we're good to go!
[-][HOLD for payment 2024-01-18] [$500] Money Request - Deleted IOU in offline mode appears when User switch to online[/-][+][C+ Checklist Needs Completion] [$500] Money Request - Deleted IOU in offline mode appears when User switch to online[/+]greg-schroeder commentedon Jan 22, 2024
Bump @fedirjh :)
fedirjh commentedon Jan 23, 2024
BugZero Checklist:
greg-schroeder commentedon Jan 25, 2024
Thanks! Added regression test and closing.