App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2024-12-05] [$250] Expense - Expense preview shows "x paid amount" when expense payment is cancelled offline

Open lanitochka17 opened this issue 1 year ago β€’ 24 comments

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
  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit an expense, approve it and pay elsewhere
  4. Go offline
  5. Click on the expense preview
  6. Click on the report header
  7. Click Cancel payment
  8. Cancel the payment
  9. Click Unapprove
  10. 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

View all open jobs on GitHub

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 OwnerCurrent Issue Owner: @joekaufmanexpensify

lanitochka17 avatar Nov 06 '24 18:11 lanitochka17

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.

melvin-bot[bot] avatar Nov 06 '24 18:11 melvin-bot[bot]

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

mkzie2 avatar Nov 06 '24 19:11 mkzie2

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

joekaufmanexpensify avatar Nov 07 '24 16:11 joekaufmanexpensify

Job added to Upwork: https://www.upwork.com/jobs/~021854562907265274025

melvin-bot[bot] avatar Nov 07 '24 16:11 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (External)

melvin-bot[bot] avatar Nov 07 '24 16:11 melvin-bot[bot]

@sobitneupane, @joekaufmanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Nov 11 '24 15:11 melvin-bot[bot]

Pending @sobitneupane review of proposals

joekaufmanexpensify avatar Nov 11 '24 15:11 joekaufmanexpensify

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 avatar Nov 12 '24 13:11 sobitneupane

@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 avatar Nov 12 '24 14:11 mkzie2

@mkzie2 Could you please update the proposal with all the details.

sobitneupane avatar Nov 12 '24 14:11 sobitneupane

@sobitneupane I updated my proposal.

mkzie2 avatar Nov 12 '24 14:11 mkzie2

Thanks for the update @mkzie2

Alternative proposal from @mkzie2 looks good to me.

πŸŽ€ πŸ‘€ πŸŽ€ C+ reviewed

sobitneupane avatar Nov 14 '24 11:11 sobitneupane

Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Nov 14 '24 11:11 melvin-bot[bot]

πŸ“£ @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 πŸ“–

melvin-bot[bot] avatar Nov 15 '24 03:11 melvin-bot[bot]

@sobitneupane The PR is ready.

mkzie2 avatar Nov 18 '24 07:11 mkzie2

PR in review

joekaufmanexpensify avatar Nov 18 '24 16:11 joekaufmanexpensify

Same

joekaufmanexpensify avatar Nov 25 '24 16:11 joekaufmanexpensify

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] avatar Nov 28 '24 14:11 melvin-bot[bot]

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)

melvin-bot[bot] avatar Nov 28 '24 14:11 melvin-bot[bot]

@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]

melvin-bot[bot] avatar Nov 28 '24 14:11 melvin-bot[bot]

@sobitneupane could you please handle checklist so we can prep to pay?

joekaufmanexpensify avatar Dec 02 '24 15:12 joekaufmanexpensify

Regression Test Proposal:

  1. Go to a workspace chat
  2. Submit, approve, and pay an expense
  3. Go offline
  4. Open the expense report
  5. Click on header --> Cancel payment
  6. Unapprove the report
  7. Go back to the workspace chat
  8. Verify that the report preview will show "x owes amount" without checkmark.

Do we agree πŸ‘ or πŸ‘Ž

sobitneupane avatar Dec 08 '24 13:12 sobitneupane

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.

sobitneupane avatar Dec 08 '24 13:12 sobitneupane

Regression test issue is here: https://github.com/Expensify/Expensify/issues/451691

joekaufmanexpensify avatar Dec 09 '24 16:12 joekaufmanexpensify

All set to issue payment. We need to pay:

  • @mkzie2 $250 for PR via Upwork.
  • @sobitneupane $250 for C+ via NewDot.

joekaufmanexpensify avatar Dec 09 '24 16:12 joekaufmanexpensify

@mkzie2 $250 sent and contract ended!

joekaufmanexpensify avatar Dec 09 '24 16:12 joekaufmanexpensify

Upwork job closed.

joekaufmanexpensify avatar Dec 09 '24 16:12 joekaufmanexpensify

@sobitneupane please request payment at your earliest convenience. Closing as this is otherwise all set!

joekaufmanexpensify avatar Dec 09 '24 16:12 joekaufmanexpensify

$250 approved for @sobitneupane

garrettmknight avatar Dec 12 '24 10:12 garrettmknight