Skip to content

[Due for payment 2025-11-18] [$250] Expense-Total amount of the split expenses is displayed incorrectly and an error occurs later #73389

Closed

Description

@mitarachim

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: V9.2.37-6
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1439/folder/13176791/41237172/969659997
Email or phone of affected tester (no customers): Slottwo1 fgg55@gmail.com
Issue reported by: Applause Internal Team
Device used: Redminote 10s android 13 phone
App Component: Money Requests

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Open workspace chat
  3. Create a manual expense for (-8)
  4. Open the expense details of transaction
  5. Tap more - split expense
  6. Remove the second split
  7. Add a split
  8. Change amount to 0.01
  9. Remove negative sign from first split by keeping cursor on first split
    10.Note the text above save button mentioning total is less than original amount
  10. Tap save

Expected Result:

Step 10 : The text above the save button is incorrect. It should say 'Total amount is 4.01 greater than the original expense,' and the user should not be able to split the expense.

Actual Result:

Step 10 : The text above the save button is displayed as 'Total amount is 3.99 less than the original expense' . Even though the correct total amount is 4.01, which is actually greater than the original expense.

Error displayed after click save button in Step 11 :

  • The sum of split amounts exceeds the original amount
  • Unexpected error submitting this expense. Please try again later.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6982894_1761276314558.Screenrecorder-2025-10-24-08-53-54-721.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021981750828087713524
  • Upwork Job ID: 1981750828087713524
  • Last Price Increase: 2025-10-24
  • Automatic offers:
    • aimane-chnaif | Reviewer | 109284062
    • mkzie2 | Contributor | 109284063
Issue OwnerCurrent Issue Owner: @sakluger

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 24, 2025
  2. melvin-bot commented on Oct 24, 2025

    @melvin-bot

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

  3. dmkt9 commented on Oct 24, 2025

    @dmkt9
    Contributor

    Proposal

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

    Step 10 : The text above the save button is displayed as 'Total amount is 3.99 less than the original expense' . Even though the correct total amount is 4.01, which is actually greater than the original expense.

    What is the root cause of that problem?

    We’ve always taken the absolute value of transactionDetailsAmount, which causes the warning message to show a smaller amount than the actual value.

    const shouldShowWarningMessage = sumOfSplitExpenses < Math.abs(transactionDetailsAmount);
    const warningMessage = shouldShowWarningMessage
    ? translate('iou.totalAmountLessThanOriginal', {amount: convertToDisplayString(Math.abs(transactionDetailsAmount) - sumOfSplitExpenses, transactionDetails.currency)})
    : '';

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

    Remove Math.abs from transactionDetailsAmount.
    Add a warningMessage for the totalAmountGreaterThanOriginal case.
    When totalAmountGreaterThanOriginal is true, we should disable the Save button.

    const shouldShowWarningMessage = sumOfSplitExpenses < Math.abs(transactionDetailsAmount);
    const warningMessage = shouldShowWarningMessage
    ? translate('iou.totalAmountLessThanOriginal', {amount: convertToDisplayString(Math.abs(transactionDetailsAmount) - sumOfSplitExpenses, transactionDetails.currency)})
    : '';

    If we don’t disable the Save button, we can remove Math.abs here to show the error message upon submission:

    if (sumOfSplitExpenses > Math.abs(transactionDetailsAmount)) {
    const difference = sumOfSplitExpenses - Math.abs(transactionDetailsAmount);
    setErrorMessage(translate('iou.totalAmountGreaterThanOriginal', {amount: convertToDisplayString(difference, transactionDetails?.currency)}));
    return;
    }

    What alternative solutions did you explore? (Optional)

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 24, 2025
  5. changed the title [-]Expense-Total amount of the split expenses is displayed incorrectly and an error occurs later[/-] [+][$250] Expense-Total amount of the split expenses is displayed incorrectly and an error occurs later[/+] on Oct 24, 2025
  6. melvin-bot commented on Oct 24, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 24, 2025
  8. melvin-bot commented on Oct 24, 2025

    @melvin-bot

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

  9. moved this to Bugs and Follow Up Issues in #expensify-bugson Oct 24, 2025
  10. mkzie2 commented on Oct 24, 2025

    @mkzie2
    Contributor

    Proposal

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

    Step 10 : The text above the save button is displayed as 'Total amount is 3.99 less than the original expense' . Even though the correct total amount is 4.01, which is actually greater than the original expense.

    What is the root cause of that problem?

    1. sumOfSplitExpenses isn't calculated correctly. We're calculating the total of the absolute amount value

    const sumOfSplitExpenses = useMemo(() => (draftTransaction?.comment?.splitExpenses ?? []).reduce((acc, item) => acc + Math.abs(item.amount ?? 0), 0), [draftTransaction]);

    1. We're comparing the absolute amount instead of the original amount value

    if (sumOfSplitExpenses > Math.abs(transactionDetailsAmount)) {

    const shouldShowWarningMessage = sumOfSplitExpenses < Math.abs(transactionDetailsAmount);

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

    1. We should remove all Math.abs when calculating the sumOfSplitExpenses here

    const sumOfSplitExpenses = useMemo(() => (draftTransaction?.comment?.splitExpenses ?? []).reduce((acc, item) => acc + Math.abs(item.amount ?? 0), 0), [draftTransaction]);

    1. Remove all Math.abs usages on SplitExpensePage when comparing/calculating the difference on SplitExpensePage
    2. We don't need to disable the confirm button since the greater than error will appear when we click on this button with the fix above

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

    NA

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  11. aimane-chnaif commented on Oct 26, 2025

    @aimane-chnaif
    Contributor

    @mkzie2's proposal looks good.
    Split amount input currently doesn't support negative value input. I think we should fix this as well.
    🎀 👀 🎀 C+ reviewed

  12. 16 remaining items

  13. changed the title [-][$250] Expense-Total amount of the split expenses is displayed incorrectly and an error occurs later[/-] [+][Due for payment 2025-11-18] [$250] Expense-Total amount of the split expenses is displayed incorrectly and an error occurs later[/+] on Nov 11, 2025
  14. melvin-bot commented on Nov 11, 2025

    @melvin-bot

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

  15. melvin-bot commented on Nov 11, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.48-1 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-11-18. 🎊

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

  16. melvin-bot commented on Nov 11, 2025

    @melvin-bot

    @aimane-chnaif @sakluger 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]

  17. sakluger commented on Nov 19, 2025

    @sakluger
    Contributor

    Payment Summary

    Contributor: @mkzie2 $250 via Upwork: Paid
    Contributor+: @aimane-chnaif $250 via Upwork

  18. aimane-chnaif commented on Nov 19, 2025

    @aimane-chnaif
    Contributor

    BugZero Checklist:

    • [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: No regression but missing case which was not considered while implementing split negative expense

    • [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:

    • [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.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Test:

    1. Create a manual expense for negative amount
    2. Open the expense details of transaction
    3. Tap more - split expense
    4. Remove the second split
    5. Add a split
    6. Change amount to 0.01
    7. Remove negative sign from first split by keeping cursor on first split
    8. Verify that: The error message shows correct calculated amount
    9. Tap save
    10. Verify that: Can't save the split.

    Do we agree 👍 or 👎

  19. sakluger commented on Nov 19, 2025

    @sakluger
    Contributor

    Thanks! I updated the payment summary.

  20. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Nov 19, 2025
  21. aimane-chnaif commented on Nov 19, 2025

    @aimane-chnaif
    Contributor

    @sakluger I haven't got payment yet.

  22. sakluger commented on Nov 21, 2025

    @sakluger
    Contributor

    Sorry @aimane-chnaif, that was my bad. All paid now. Thank you for the bump!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions