[HOLD for payment 2024-12-05] [$250] Expense - Expense preview shows "x paid amount" when expense payment is cancelled offline
If you havenβt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.58-1 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause - Internal Team
Action Performed:
Precondition:
- Workflows are enabled and Add approvals feature is enabled
- Go to staging.new.expensify.com
- Go to workspace chat
- Submit an expense, approve it and pay elsewhere
- Go offline
- Click on the expense preview
- Click on the report header
- Click Cancel payment
- Cancel the payment
- Click Unapprove
- Click on the report subtitle to return to the main chat
Expected Result:
The expense preview will show "x owes amount" without checkmark because the expense payment is cancelled offline
Actual Result:
The expense preview shows "x paid amount" when expense payment is cancelled offline
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
- [x] Android: Standalone
- [x] Android: HybridApp
- [x] Android: mWeb Chrome
- [x] iOS: Standalone
- [x] iOS: HybridApp
- [x] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [x] MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/5e219d01-3bef-411c-8271-a6869e272d11
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021854562907265274025
- Upwork Job ID: 1854562907265274025
- Last Price Increase: 2024-11-07
- Automatic offers:
- mkzie2 | Contributor | 104908738
Issue Owner
Current Issue Owner: @joekaufmanexpensify
Triggered auto assignment to @joekaufmanexpensify (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.
Edited by proposal-police: This proposal was edited at 2024-11-12 14:23:20 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The expense preview shows "x paid amount" when expense payment is cancelled offline
What is the root cause of that problem?
iouSettled condition is true if isSettled function returns true or action.childStatusNum is CONST.REPORT.STATUS_NUM.REIMBURSED
https://github.com/Expensify/App/blob/c755314f826a771ea9b3eb1aa5c1dd92a5aae483/src/components/ReportActionItem/ReportPreview.tsx#L135
After paying the expense, action.childStatusNum is updated correctly. But when we cancel the payment and unapproved the report, this status isn't updated (only the statusNum of the expense report is updated).
It leads iouSettled is still true because this condition action?.childStatusNum === CONST.REPORT.STATUS_NUM.REIMBURSED is still true
https://github.com/Expensify/App/blob/c755314f826a771ea9b3eb1aa5c1dd92a5aae483/src/components/ReportActionItem/ReportPreview.tsx#L135
And the preview is displayed x paid amount
What changes do you think we should make in order to solve the problem?
We should only check action?.childStatusNum when the iou report data isn't available
const iouSettled = iouReport ? ReportUtils.isSettled(iouReportID) : action?.childStatusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;
https://github.com/Expensify/App/blob/c755314f826a771ea9b3eb1aa5c1dd92a5aae483/src/components/ReportActionItem/ReportPreview.tsx#L135
What alternative solutions did you explore? (Optional)
When we cancel the payment and unapproved the report we should update childStateNum and childStatusNum of the parent report action in optimistic data and reset it in failure data with the value like here and here
The value of childStateNum and childStatusNum will be the same as stateNum and statusNum values that we updated for the expense report. Here is an example
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.parentReportID}`,
value: {
[expenseReport.parentReportActionID]: {
childStateNum: stateNum,
childStatusNum: statusNum,
},
},
},
https://github.com/Expensify/App/blob/c755314f826a771ea9b3eb1aa5c1dd92a5aae483/src/libs/actions/IOU.ts#L7551-L7552
https://github.com/Expensify/App/blob/c755314f826a771ea9b3eb1aa5c1dd92a5aae483/src/libs/actions/IOU.ts#L7351-L7352
Reproduced. Yeah, if we're showing Approve again on the report preview if you unapproved while offline, it seems odd that we are showing the report as paid when it was also canceled offline.
Seems like this is a pattern B situation based on the unapproved and payment cancel comments having .5 opacity. Not sure if we need to do something to signal on the report preview to signal pattern B too though.
https://github.com/user-attachments/assets/98b37b88-ea48-469a-ac1d-91b57398449e
Job added to Upwork: https://www.upwork.com/jobs/~021854562907265274025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (External)
@sobitneupane, @joekaufmanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Pending @sobitneupane review of proposals
Thanks for the proposal @mkzie2
I prefer the alternative proposal as it directly addresses the root cause of the issue.
When we cancel the payment and unapproved the report we should update childStateNum and childStatusNum of the parent report action in optimistic data and reset it in failure data with the value like here and here
Could you clarify what values we should update childStateNum and childStatusNum to? It would be helpful if you could provide additional details for this alternative solution.
@sobitneupane In two places, we will update childStateNum, childStatusNum with the same stateNum and statusNum value that we updated for the expense report
https://github.com/Expensify/App/blob/c755314f826a771ea9b3eb1aa5c1dd92a5aae483/src/libs/actions/IOU.ts#L7551-L7552
https://github.com/Expensify/App/blob/c755314f826a771ea9b3eb1aa5c1dd92a5aae483/src/libs/actions/IOU.ts#L7351-L7352
@mkzie2 Could you please update the proposal with all the details.
@sobitneupane I updated my proposal.
Thanks for the update @mkzie2
Alternative proposal from @mkzie2 looks good to me.
π π π C+ reviewed
Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
π£ @mkzie2 π An offer has been automatically sent to your Upwork account for the Contributor role π Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review π§βπ» Keep in mind: Code of Conduct | Contributing π
@sobitneupane The PR is ready.
PR in review
Same
Reviewing label has been removed, please complete the "BugZero Checklist".
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.67-9 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/52687
If no regressions arise, payment will be issued on 2024-12-05. :confetti_ball:
For reference, here are some details about the assignees on this issue:
- @sobitneupane requires payment through NewDot Manual Requests
- @mkzie2 requires payment automatic offer (Contributor)
@sobitneupane @joekaufmanexpensify @sobitneupane The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
@sobitneupane could you please handle checklist so we can prep to pay?
Regression Test Proposal:
- Go to a workspace chat
- Submit, approve, and pay an expense
- Go offline
- Open the expense report
- Click on header --> Cancel payment
- Unapprove the report
- Go back to the workspace chat
- Verify that the report preview will show "x owes amount" without checkmark.
Do we agree π or π
BugZero Checklist:
- [x] [Contributor] Classify the bug:
Bug classification
Source of bug:
- [ ] 1a. Result of the original design (eg. a case wasn't considered)
- [x] 1b. Mistake during implementation
- [ ] 1c. Backend bug
- [ ] 1z. Other:
Where bug was reported:
- [x] 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
- [ ] 2b. Reported on staging (eg. found during regression or PR testing)
- [ ] 2d. Reported on a PR
- [ ] 2z. Other:
Who reported the bug:
- [ ] 3a. Expensify user
- [ ] 3b. Expensify employee
- [ ] 3c. Contributor
- [x] 3d. QA
- [ ] 3z. Other:
-
[x] [Contributor] 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: https://github.com/Expensify/App/pull/44229#issuecomment-2525833995
-
[x] [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:
-
[x] [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression test issue is here: https://github.com/Expensify/Expensify/issues/451691
All set to issue payment. We need to pay:
- @mkzie2 $250 for PR via Upwork.
- @sobitneupane $250 for C+ via NewDot.
@mkzie2 $250 sent and contract ended!
Upwork job closed.
@sobitneupane please request payment at your earliest convenience. Closing as this is otherwise all set!
$250 approved for @sobitneupane