Skip to content
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

[$250] Expense - Amount is not automatically updated when sending track expense to WS with expenses #54967

Open
3 of 8 tasks
vincdargento opened this issue Jan 8, 2025 · 47 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@vincdargento
Copy link

vincdargento commented Jan 8, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.82-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
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): ibellicotest+161@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 - Android 12 - Chrome / Windows 10 - Chrome
App Component: Money Requests

Action Performed:

  1. Open the staging.new.expensify.com website.
  2. Open any workspace chat.
  3. Tap on the "+" button and select "Create Expense"
  4. Complete the expense creation flow.
  5. Navigate back to inbox and open self DM.
  6. Tap on the "+" button and select "Create Expense"
  7. Complete the expense creation flow.
  8. When whisper message is displayed, select "Share with my accountant" option.
  9. Select the workspace where the previous expense was submitted and send the track expense to it.
  10. Check the amount displayed in the expense report preview.

Expected Result:

Amount should be automatically updated on the expenses report preview when submitting the track expense to chat.

Actual Result:

When a track expense is submitted to a workspace chat that already has an expense on it, using the "Share with my accountant" option, the expenses report preview, shows only the amount of the first expense and is not automatically updated. Also, the "Pay Elsewhere" button shows an incorrect amount.
Amounts are updated only after opening expenses report and returning to chat,

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021878876293261303313
  • Upwork Job ID: 1878876293261303313
  • Last Price Increase: 2025-03-10
Issue OwnerCurrent Issue Owner: @s77rt
@vincdargento vincdargento added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 8, 2025
Copy link

melvin-bot bot commented Jan 8, 2025

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

@jacobkim9881
Copy link
Contributor

[info] [Network] Finished API request in 203ms - {"command":"GetMissingOnyxMessages","jsonCode":200,"requestID":"8ff16711ca2aeaa3-ICN"} 
response: 
{
    "key": "report_4032014771979031",
    "onyxMethod": "merge",
    "value": {
        "chatType": "",
        "lastActorAccountID": 18943404,
        "lastMessageText": "",
        "lastVisibleActionCreated": "2025-01-09 03:39:42.157",
        "managerID": 18943404,
////////////////////////////////
        "nonReimbursableTotal": -400,
////////////////////////////////
        "ownerAccountID": 18943404,
        "parentReportActionID": "4915136744835963433",
        "parentReportID": "8073481827929905",
        "policyID": "E5988D7694E5985B",
        "reportID": "4032014771979031",
        "reportName": "Expense Report #4032014771979031",
        "stateNum": 1,
        "statusNum": 1,
/////////////////////////////
        "total": "-42500",
/////////////////////////////
        "type": "expense",
        "visibility": ""
    }
}

The paybutton should show 425 but it shows 421 because the amount at the button is total - nonReimbursableTotal. W/o nonReimbursableTotal, the amounts will be same to 425. It seems nonReimbursableTotal should not be added for this case.

@melvin-bot melvin-bot bot added the Overdue label Jan 13, 2025
@OfstadC OfstadC added the External Added to denote the issue can be worked on by a contributor label Jan 13, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

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

@melvin-bot melvin-bot bot changed the title Expense - Amount is not automatically updated when sending track expense to WS with expenses [$250] Expense - Amount is not automatically updated when sending track expense to WS with expenses Jan 13, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 13, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

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

@melvin-bot melvin-bot bot removed the Overdue label Jan 13, 2025
@s77rt
Copy link
Contributor

s77rt commented Jan 13, 2025

@jacobkim9881 Can you please use the proposal template?

@jacobkim9881
Copy link
Contributor

Proposal

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

After submitting tracked expense, report preview shows false amount.

What is the root cause of that problem?

nonReimbursableTotal given from BE API should not have a value.

As a result of submitting tracked expense, GetMissingOnyxMessages gives this response:

[info] [Network] Finished API request in 203ms - {"command":"GetMissingOnyxMessages","jsonCode":200,"requestID":"8ff16711ca2aeaa3-ICN"} 
response: 
{
    "key": "report_4032014771979031",
    "onyxMethod": "merge",
    "value": {
        "chatType": "",
        "lastActorAccountID": 18943404,
        "lastMessageText": "",
        "lastVisibleActionCreated": "2025-01-09 03:39:42.157",
        "managerID": 18943404,
////////////////////////////////
        "nonReimbursableTotal": -400,
////////////////////////////////
        "ownerAccountID": 18943404,
        "parentReportActionID": "4915136744835963433",
        "parentReportID": "8073481827929905",
        "policyID": "E5988D7694E5985B",
        "reportID": "4032014771979031",
        "reportName": "Expense Report #4032014771979031",
        "stateNum": 1,
        "statusNum": 1,
/////////////////////////////
        "total": "-42500",
/////////////////////////////
        "type": "expense",
        "visibility": ""
    }
}

And the total is calculated here:

<AnimatedSettlementButton
shouldUseSuccessStyle={!hasHeldExpenses}
onlyShowPayElsewhere={onlyShowPayElsewhere}
isPaidAnimationRunning={isPaidAnimationRunning}
isApprovedAnimationRunning={isApprovedAnimationRunning}
canIOUBePaid={canIOUBePaidAndApproved || isPaidAnimationRunning}
onAnimationFinish={stopAnimation}
formattedAmount={getSettlementAmount() ?? ''}

getSettlementAmount comes from reimbursableSpend of getMoneyRequestSpendBreakdown here:

App/src/libs/ReportUtils.ts

Lines 3050 to 3076 in 58343c7

function getMoneyRequestSpendBreakdown(report: OnyxInputOrEntry<Report>, allReportsDict?: OnyxCollection<Report>): SpendBreakdown {
const allAvailableReports = allReportsDict ?? allReports;
let moneyRequestReport: OnyxEntry<Report>;
if (report && (isMoneyRequestReport(report) || isInvoiceReport(report))) {
moneyRequestReport = report;
}
if (allAvailableReports && report?.iouReportID) {
moneyRequestReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`];
}
if (moneyRequestReport) {
let nonReimbursableSpend = moneyRequestReport.nonReimbursableTotal ?? 0;
let totalSpend = moneyRequestReport.total ?? 0;
if (nonReimbursableSpend + totalSpend !== 0) {
// There is a possibility that if the Expense report has a negative total.
// This is because there are instances where you can get a credit back on your card,
// or you enter a negative expense to “offset” future expenses
nonReimbursableSpend = isExpenseReport(moneyRequestReport) ? nonReimbursableSpend * -1 : Math.abs(nonReimbursableSpend);
totalSpend = isExpenseReport(moneyRequestReport) ? totalSpend * -1 : Math.abs(totalSpend);
const totalDisplaySpend = totalSpend;
const reimbursableSpend = totalDisplaySpend - nonReimbursableSpend;
return {
nonReimbursableSpend,
reimbursableSpend,
totalDisplaySpend,

According to getMoneyRequestSpendBreakdown, amount is calculated by reimbursableSpend = totalDisplaySpend - nonReimbursableSpend. Applied by this, the amount is 42100 = 42500 - 400. 400 is nonReimbursableTotal but I think submitted track expense should not be none reimbursable.

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

nonReimbursableTotal should be 0 in GetMissingOnyxMessages of BE API for submitting tracked expense.

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

N/A

What alternative solutions did you explore? (Optional)

N/A

@s77rt
Copy link
Contributor

s77rt commented Jan 14, 2025

@jacobkim9881 Thanks for the proposal. Your RCA is not correct. I don't see why nonReimbursableTotal should be 0. Track expenses are non-reimbursable expenses.

@garrettmknight garrettmknight moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Jan 14, 2025
@huult
Copy link
Contributor

huult commented Jan 15, 2025

This is a backend issue. When we call ShareTrackedExpense, the total is not included in the report. We should update ShareTrackedExpense to function like RequestMoney by returning the total in the report

Image

@s77rt
Copy link
Contributor

s77rt commented Jan 15, 2025

@huult Can you please follow the proposal template? Also please check if this bug occurs offline too (whether we are missing optimistic data or if it's really a backend issue)

Copy link

melvin-bot bot commented Jan 20, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Jan 20, 2025
@s77rt
Copy link
Contributor

s77rt commented Jan 20, 2025

Still looking for proposals

@melvin-bot melvin-bot bot removed the Overdue label Jan 20, 2025
Copy link

melvin-bot bot commented Jan 22, 2025

@OfstadC @s77rt this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@s77rt
Copy link
Contributor

s77rt commented Jan 22, 2025

Same ^

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@melvin-bot melvin-bot bot added the Overdue label Jan 27, 2025
@s77rt
Copy link
Contributor

s77rt commented Jan 27, 2025

Still looking for proposals

@melvin-bot melvin-bot bot added the Overdue label Feb 17, 2025
@s77rt
Copy link
Contributor

s77rt commented Feb 17, 2025

Still looking for proposals

@melvin-bot melvin-bot bot removed the Overdue label Feb 17, 2025
Copy link

melvin-bot bot commented Feb 21, 2025

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

@melvin-bot melvin-bot bot added the Overdue label Feb 21, 2025
@s77rt
Copy link
Contributor

s77rt commented Feb 21, 2025

Same ^

@melvin-bot melvin-bot bot removed the Overdue label Feb 21, 2025
Copy link

melvin-bot bot commented Feb 24, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Feb 24, 2025
@s77rt
Copy link
Contributor

s77rt commented Feb 24, 2025

Same ^

@melvin-bot melvin-bot bot removed the Overdue label Feb 24, 2025
Copy link

melvin-bot bot commented Feb 28, 2025

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

@melvin-bot melvin-bot bot added the Overdue label Feb 28, 2025
@s77rt
Copy link
Contributor

s77rt commented Feb 28, 2025

Same ^

@melvin-bot melvin-bot bot removed the Overdue label Feb 28, 2025
Copy link

melvin-bot bot commented Mar 3, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Mar 3, 2025
@s77rt
Copy link
Contributor

s77rt commented Mar 3, 2025

Still looking for proposals

@melvin-bot melvin-bot bot removed the Overdue label Mar 3, 2025
@jacobkim9881
Copy link
Contributor

I don't see why nonReimbursableTotal should be 0. Track expenses are non-reimbursable expenses.

So "Share it with my accountant" is within track expense? I think the expense shared with an accountant is not track expense.

For an example, when I have "Submit it to someone" to another account on self DM, it has "nonReimbursableTotal" as 0. As it is moved into a chat room with another account, it isn't a track expense.

On the other hand "Share it with my accountant" to a workspace has none 0 "nonReimbursableTotal" value. Track expenses in self DM should have none 0 value but the shared expense with an accountant is moved into a workspace from self DM.

@s77rt
Copy link
Contributor

s77rt commented Mar 5, 2025

@jacobkim9881 Can you still reproduce the bug?

@jacobkim9881
Copy link
Contributor

the expenses report preview, shows only the amount of the first expense and is not automatically updated

Oh, it isn't reproducible.

@jacobkim9881
Copy link
Contributor

Also, the "Pay Elsewhere" button shows an incorrect amount.

However it isn't an issue? As a second check, I think the amount can be different if "Share it with my accountant" is a track expense.

@s77rt
Copy link
Contributor

s77rt commented Mar 7, 2025

@jacobkim9881 The amount shouldn't change as track expenses are non-reimbursable and you can't pay a non-reimbursable expenses.

@s77rt
Copy link
Contributor

s77rt commented Mar 7, 2025

@OfstadC We can close this as it's no longer reproducible

Copy link

melvin-bot bot commented Mar 10, 2025

@s77rt Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Mar 10, 2025
Copy link

melvin-bot bot commented Mar 10, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@s77rt
Copy link
Contributor

s77rt commented Mar 10, 2025

@OfstadC Let's close this one

@melvin-bot melvin-bot bot removed the Overdue label Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

6 participants