Skip to content

[$250] Expense - Tax amount changes to zero after creating negative expense with non-zero tax rate #83087

Closed

Description

@jponikarchuk

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.3.24-1
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-5896/folder/13176868/41237330/1203273528
Email or phone of affected tester (no customers): soidnjosdjojdnosnjdosjd@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Taxes are enabled.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Click + > Create expense > Manual.
  4. Enter negative amount > Next.
  5. On confirm page, click Tax field and select 5% rate.
    → Tax amount is not zero when 5% rate is selected for negative amount.
  6. Click Create expense.
  7. Open the expense.

Expected Result:

Tax amount should be non-zero and same as confirm page in Step 5 when 5% rate is selected for negative amount.

Actual Result:

Tax amount changes to zero after creating negative expense with non-zero tax rate.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7083689_1771608312440.5.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @CortneyOfstad
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022024903783911413849
  • Upwork Job ID: 2024903783911413849
  • Last Price Increase: 2026-02-20

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 20, 2026
  2. melvin-bot commented on Feb 20, 2026

    @melvin-bot

    Triggered auto assignment to @CortneyOfstad (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. MelvinBot commented on Feb 20, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When creating a negative expense (e.g., -$5.00) with a non-zero tax rate (e.g., 5%), the tax amount displays correctly on the confirmation page but becomes zero after the expense is created.

    What is the root cause of that problem?

    The root cause is in MoneyRequestConfirmationList.tsx at line 545, where the taxableAmount is set to the raw transaction?.amount without taking the absolute value:

    const taxableAmount = isDistanceRequest ? DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, distance) : (transaction?.amount ?? 0);

    For a negative expense (e.g., -$5.00), transaction.amount is -500 (in smallest currency units). This negative value is passed to calculateTaxAmount (TransactionUtils/index.ts:2025-2033), which preserves the sign, producing a negative tax amount (e.g., -0.24 for 5% tax). This negative tax gets stored on the draft transaction via setMoneyRequestTaxAmount at line 558.

    The confirmation page appears to show the correct tax because the display function getTaxAmount (TransactionUtils/index.ts:937-941) applies Math.abs before displaying — this masks the underlying negative value.

    When the user confirms, IOURequestStepConfirmation.tsx reads the raw negative taxAmount from the draft (line 274) and passes it directly to requestMoney, which sends the negative value to the backend API (IOU/index.ts:6756). The backend likely interprets the negative tax amount as zero or invalid.

    Notably, the tax rate page (IOURequestStepTaxRatePage.tsx:82) handles this correctly by using getAmount(currentTransaction, false, true) which returns a positive value, but the MoneyRequestConfirmationList useEffect then overwrites this correct value with its own negative calculation when the confirmation page renders.

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

    In src/components/MoneyRequestConfirmationList.tsx at line 545, wrap the non-distance taxable amount in Math.abs:

    // Current (buggy):
    const taxableAmount = isDistanceRequest ? DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, distance) : (transaction?.amount ?? 0);
    
    // Fixed:
    const taxableAmount = isDistanceRequest ? DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, distance) : Math.abs(transaction?.amount ?? 0);

    This ensures calculateTaxAmount always receives a positive amount, producing a positive tax value that correctly flows through the rest of the creation pipeline.

    What alternative solutions did you explore? (Optional)

    1. Fix at IOURequestStepConfirmation.tsx:274 — Apply Math.abs when reading transactionTaxAmount. This would work but is a downstream band-aid; it's better to fix the calculation at the source so the draft always stores the correct positive tax value.

    2. Fix inside calculateTaxAmount — Make it always return Math.abs of its result. This would work but changes the function's general contract; the current sign-preserving behavior may be intentional for other callers.

    3. Fix at IOU/index.ts:3522 — Apply Math.abs in getMoneyRequestInformation when building the optimistic transaction. This would partially work (for expense reports, the double-negation already accidentally produces the correct value), but wouldn't fix the underlying incorrect draft value.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 20, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 20, 2026
  6. melvin-bot commented on Feb 20, 2026

    @melvin-bot

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

  7. changed the title [-]Expense - Tax amount changes to zero after creating negative expense with non-zero tax rate[/-] [+][$250] Expense - Tax amount changes to zero after creating negative expense with non-zero tax rate[/+] on Feb 20, 2026
  8. melvin-bot commented on Feb 20, 2026

    @melvin-bot
  9. btkcodedev commented on Feb 20, 2026

    @btkcodedev
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-02-20 18:36:40 UTC.

    Proposal

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

    When creating a negative manual expense (for example, -$5.00) with a non-zero tax rate (for example, 5%), tax appears non-zero on confirmation, but after creating the expense the final tax becomes 0.

    What is the root cause of that problem?

    The confirmation flow was calculating tax from a signed transaction amount, so negative expenses produced a negative tax value internally.

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

    Use normalized IOU amount (getAmount) when calculating non-distance taxable amount in confirmation, so tax is always computed from a positive base for manual IOU requests.

    [~/App/src/components/MoneyRequestConfirmationList.tsx:546]

    const taxableAmount = isDistanceRequest ? DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, distance) : getAmount(transaction);

    This is the correct source-level fix because getAmount already enforces IOU sign normalization for this flow
    Add regression coverage for negative manual expenses with tax:

    [~/App/tests/ui/components/IOURequestStepConfirmationPageTest.tsx:357]

    it('should keep tax amount positive for manual negative expenses', async () => {
        ...
        amount: -500,
        taxCode: 'taxRate1',
        ...
        expect(transaction?.taxAmount).toBe(24);
        expect(transaction?.taxAmount).toBeGreaterThan(0);
    });

    What alternative solutions did you explore? (Optional)

    None

  10. abbasifaizan70 commented on Feb 20, 2026

    @abbasifaizan70
    Contributor

    Proposal

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

    Tax amount changes to zero after creating negative expense with non-zero tax rate.

    What is the root cause of that problem?

    On the confirm page, tax is computed correctly for negative amounts: MoneyRequestConfirmationList uses transaction?.amount (negative) with calculateTaxAmount, so the draft gets a negative tax amount and the UI shows the correct non-zero tax.

    When the user taps Create expense, the TRACK_EXPENSE API is called with taxAmount from the draft (a negative number for negative expenses). The backend likely expects a positive tax amount and either rejects or zeroes negative tax, so the stored transaction is returned with taxAmount: 0. The client then shows zero tax when the expense is opened.

    Relevant flow:

    • Confirm page passes transaction?.taxAmount (negative) into track expense:

    const transactionTaxAmount = transaction?.taxAmount ?? 0;

    • TRACK_EXPENSE parameters send that value as-is:

    tag,
    taxCode,
    taxAmount,

    • Optimistic transaction is built with taxAmount: taxAmount ? -taxAmount : undefined (so a negative draft tax becomes positive in the stored transaction), but the server response overwrites the transaction with the backend value (taxAmount: 0):

    tag,
    taxCode,
    taxAmount: taxAmount ? -taxAmount : undefined,
    billable,

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

    Send the tax amount as an absolute value in the TRACK_EXPENSE API request so the backend receives a positive value and can persist it. The client already applies the correct sign for display in expense report context via getTaxAmount(transaction, isFromExpenseReport) in TransactionUtils, which returns the negated value for expense reports, so the displayed tax will remain correct.

    File: App/src/libs/actions/IOU/index.ts

                const parameters: TrackExpenseParams = {
                    amount,
                    attendees: attendees ? JSON.stringify(attendees) : undefined,
                    currency,
                    comment,
                    distance: distance !== undefined ? roundToTwoDecimalPlaces(distance) : undefined,
                    created,
                    merchant,
                    iouReportID: iouReport?.reportID,
                    chatReportID: optimisticReportID ? undefined : chatReport?.reportID,
                    transactionID: transaction?.transactionID,
                    reportActionID: iouAction?.reportActionID,
                    createdChatReportActionID,
                    createdIOUReportActionID,
                    reportPreviewReportActionID: reportPreviewAction?.reportActionID,
                    optimisticReportID,
                    optimisticReportActionID,
                    policyID: undefined,
                    receipt: isFileUploadable(trackedReceipt) ? trackedReceipt : undefined,
                    receiptState: trackedReceipt?.state,
                    reimbursable,
                    category,
                    tag,
                    taxCode,
    -               taxAmount,
    +               taxAmount: Math.abs(taxAmount ?? 0),
                    billable,
                    receiptGpsPoints: gpsPoint ? JSON.stringify(gpsPoint) : undefined,
                    transactionThreadReportID,
                    createdReportActionIDForThread,
                    waypoints: sanitizedWaypoints,
                    customUnitRateID,
                    description: parsedComment,
                    gpsCoordinates,
                    isDistance: isGPSDistanceRequest || isMapDistanceRequest(transaction) || isManualDistanceRequestTransactionUtils(transaction),
                };
  11. github-actions commented on Feb 20, 2026

    @github-actions
    Contributor

    ⚠️ @btkcodedev Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  12. 11 remaining items

  13. rojiphil commented on Feb 27, 2026

    @rojiphil
    Contributor

    Melvin's proposal LGTM.
    🎀👀🎀 C+ reviewed

  14. melvin-bot commented on Feb 27, 2026

    @melvin-bot

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

  15. removed
    ExternalAdded to denote the issue can be worked on by a contributor
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 27, 2026
  16. inimaga commented on Feb 27, 2026

    @inimaga
    Contributor

    Now merged.

  17. rojiphil commented on Mar 16, 2026

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

    • [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: Not Required. The existing checklist is good enough to capture such issues.

    • [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 Proposal Template

    Regression Test Proposal

    Precondition:

    Test:

    1. Enable taxes on a workspace
    2. Go to the workspace chat
    3. Click + > Create expense > Manual
    4. Enter a negative amount (e.g., -$5.00) > Next
    5. On the confirm page, click Tax field and select a non-zero tax rate (e.g., 5%)
    6. Verify the tax amount is non-zero on the confirm page
    7. Click Create expense
    8. Open the created expense
    9. Verify the tax amount is non-zero and matches the confirm page value

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-311c-aab8-33ea-b5f9e479d894
  18. mallenexpensify commented on Mar 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @rojiphil due $250 via NewDot

    ^ Test case created

    thx

  19. quinthar commented on Apr 13, 2026

    @quinthar
    Contributor

    Approved $250 to @rojiphil

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions