Skip to content

[Due for payment 2025-05-22] [$250] Expense - Incorrect payment amount in LHN and report when report has track & submitted expense #61080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
8 of 16 tasks
lanitochka17 opened this issue Apr 29, 2025 · 17 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Apr 29, 2025

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.1.33-5
Reproducible in staging?: Y
Reproducible in production?: Y
**If this was caught during regression testing, add the test name, ID and lin
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Account has self DM
  • Log in with Expensifail account
  1. Go to staging.new.expensify.com
  2. Go to self DM
  3. Track a manual expense of amount RM100 (any currency)
  4. Click Share it with my account
  5. Click New workspace (if acccount already has workspace)
  6. Enter merchant, select a category and click Create expense
  7. On workspace chat, submit another expense of amount RM120 (any currency) via + menu
  8. Click on the expense preview
  9. Click More > Submit (if workspace has enabled delay submissions)
  10. Click Pay elsewhere
  11. Note that the paid system message in the expense report is "paid MYR 120.00 elsewhere", whereas LHN shows "paid MYR 220.00 elsewhere"
  12. Click More > Cancel payment
  13. Click Cancel payment
  14. Note that the payment cancelation system message in the expense report and LHN is "canceled the MYR 220.00 payment", when RM120.00 was paid in Step 11

Expected Result:

In Step 11, the paid system message in the expense report and LHN should show "paid MYR 120.00 elsewhere"
In Step 14, the payment cancelation system message in the expense report and LHN should be "canceled the MYR 120.00 payment" because RM120.00 was paid in Step 11 (the payment button also shows Pay RM120.00 elsewhere)

Actual Result:

In Step 11, the paid system message in the expense report is "paid MYR 120.00 elsewhere", whereas LHN shows "paid MYR 220.00 elsewhere"
In Step 14, the payment cancelation system message in the expense report and LHN is "canceled the MYR 220.00 payment", when RM120.00 was paid in Step 11

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6816480_1745936374999.20250429_220556.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021917864478821489895
  • Upwork Job ID: 1917864478821489895
  • Last Price Increase: 2025-05-01
  • Automatic offers:
    • FitseTLT | Contributor | 107138473
Issue OwnerCurrent Issue Owner: @sonialiap
@lanitochka17 lanitochka17 added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Apr 29, 2025
Copy link

melvin-bot bot commented Apr 29, 2025

Triggered auto assignment to @sonialiap (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.

@FitseTLT
Copy link
Contributor

FitseTLT commented Apr 29, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-04-29 15:17:38 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Expense - Incorrect payment amount in LHN and report when report has track & submitted expense

What is the root cause of that problem?

  1. We are using total spend of the break down here for paid LHN instead of the reimbursableSpend
    const totalAmount = getMoneyRequestSpendBreakdown(report).totalDisplaySpend;
  2. But for the case of canceled payment we use the originalMessage.amount value

    App/src/libs/ReportUtils.ts

    Lines 3159 to 3160 in 62fdc63

    const originalMessage = getOriginalMessage(reportAction);
    const amount = originalMessage?.amount;

    which is wrongly set to the total value by the backend

What changes do you think we should make in order to solve the problem?

  1. We should use reimbursableSpend
    const totalAmount = getMoneyRequestSpendBreakdown(report).reimbursableSpend;

but the amount is used for other types of action in the function so if needed we can use the total spend for other cases as approve here

App/src/libs/ReportUtils.ts

Lines 4196 to 4200 in 62fdc63

if (isReportApproved({report}) && isPaidGroupPolicy(report)) {
return translateLocal('iou.managerApprovedAmount', {
manager: payerName ?? '',
amount: formattedAmount,
});

and only add a new remibursable amount variable and use it for the cases that apply like our case of pay here.
Or alternatively we can take the correct amount from the the iouAction originalMessage.amount to align with what we display in the report screen here)

  1. The BE should be fixed to return the canceled payment report action's originalMessage.amount equal to reimbursable amount instead of the total. Additionally, the original message we are setting optimistically should be fixed. We should deduct the iouReport nonReimbursableAmount as we are doing for pay here
    const optimisticReportAction = buildOptimisticCancelPaymentReportAction(expenseReport.reportID, -(expenseReport.total ?? 0), expenseReport.currency ?? '');
const optimisticReportAction = buildOptimisticCancelPaymentReportAction(
        expenseReport.reportID,
        -((expenseReport.total ?? 0) - (expenseReport?.nonReimbursableTotal ?? 0)),
        expenseReport.currency ?? '',
    );

But if we are ok with a FE workaround we can calculate the reimbursable amount from the iou report's break down just like we are doing here

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

We can make test to assert that the canceled payment action created has got the correct amount with the non-reimbursable amount deducted from the total.

What alternative solutions did you explore? (Optional)

@sonialiap sonialiap added the External Added to denote the issue can be worked on by a contributor label May 1, 2025
@melvin-bot melvin-bot bot changed the title Expense - Incorrect payment amount in LHN and report when report has track & submitted expense [$250] Expense - Incorrect payment amount in LHN and report when report has track & submitted expense May 1, 2025
Copy link

melvin-bot bot commented May 1, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 1, 2025
Copy link

melvin-bot bot commented May 1, 2025

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

@jjcoffee
Copy link
Contributor

jjcoffee commented May 1, 2025

@FitseTLT's proposal makes sense to me. We are using reimbursableSpend for the pay button's display.

const {totalDisplaySpend, reimbursableSpend} = getMoneyRequestSpendBreakdown(iouReport);

return convertToDisplayString(reimbursableSpend, iouReport?.currency);

We do need a BE fix for the cancelled message as well.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented May 1, 2025

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

@dangrous
Copy link
Contributor

dangrous commented May 1, 2025

Can look at the backend here, though probably not until tomorrow! Front end update sounds good too

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 1, 2025
Copy link

melvin-bot bot commented May 1, 2025

📣 @FitseTLT 🎉 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 melvin-bot bot added the Overdue label May 5, 2025
Copy link

melvin-bot bot commented May 5, 2025

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

@jjcoffee
Copy link
Contributor

jjcoffee commented May 5, 2025

@FitseTLT I think you can get started on the FE PR for this as it doesn't rely on BE changes.

@dangrous
Copy link
Contributor

dangrous commented May 5, 2025

backend is merged! Not yet deployed but shouldn't be long since it's in the repo without staging.

@melvin-bot melvin-bot bot removed the Overdue label May 5, 2025
@sonialiap
Copy link
Contributor

BE has been deployed to production https://github.com/Expensify/Auth/pull/15166

@jjcoffee
Copy link
Contributor

jjcoffee commented May 7, 2025

@FitseTLT Can you let us know when we can expect a PR?

@FitseTLT
Copy link
Contributor

FitseTLT commented May 7, 2025

Will draft the pr today

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 15, 2025
@melvin-bot melvin-bot bot changed the title [$250] Expense - Incorrect payment amount in LHN and report when report has track & submitted expense [Due for payment 2025-05-22] [$250] Expense - Incorrect payment amount in LHN and report when report has track & submitted expense May 15, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 15, 2025
Copy link

melvin-bot bot commented May 15, 2025

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

Copy link

melvin-bot bot commented May 15, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.45-21 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-05-22. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented May 15, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
None yet
Development

No branches or pull requests

5 participants