Skip to content

Expense - Tax amount field is not negative when amount is negative #103664

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.7-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #102175
Email or phone of affected tester (no customers): jsoidjndoiniodnsjojd@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Enable Taxes.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Click + > Create expense > Manual.
  4. Enter negative amount.
  5. Click Tax field and select 5% rate.

Expected Result:

Tax amount field will be negative.

Actual Result:

Tax amount field is not negative when amount is negative.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

To be added by Applause Leads

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7282539

Activity

  1. applause-bot commented on Oct 9, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/2a79237905f839422234ca59f8ace23e7437aaa78310155c4caf06089c8c3032

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 9, 2026
  3. melvin-bot commented on Oct 9, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #102175

  4. melvin-bot commented on Oct 9, 2026

    @melvin-bot

    @grgia you have been assigned to this deploy blocker because you reviewed the offending PR: #102175

  5. melvin-bot commented on Oct 9, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  6. github-actions commented on Oct 9, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  7. MelvinBot commented on Oct 9, 2026

    @MelvinBot
    Contributor

    Deploy Blocker Investigation

    Recommendation: demote, don't revert. Show negative tax amount for negative expenses on the expense details page did not cause this. The create-expense flow has always shown a positive tax for a negative amount, and production behaves the same way. The PR only changed the details page of an existing expense. QA found this gap while testing that PR, which is why it was auto-linked.

    Root cause: The manual create flow forces the tax amount positive in several places. None of them changed in this deploy:

    Suggested next step: An internal engineer (for example, grgia) should confirm and remove DeployBlockerCash. Track the create-flow fix as a follow-up under [Exploratory] Web - Taxes - Inconsistent tax amount display on report with negative expenses.

    Investigation details

    What PR #102175 changed. It touched only MoneyRequestView.tsx, ReportUtils.ts, TransactionUtils/index.ts, and tests. It removed Math.abs() from the details-page tax display. In TransactionUtils, it refactored getTaxAmount into normalizeTaxAmountSign without changing behavior: isFromExpenseReport = false still returns Math.abs(...), as before. The create flow calls it with false, so the result is unchanged.

    Other PRs on the deploy. I checked every PR on the Deploy Checklist: New Expensify 2026-10-09 that touches tax or confirm-page code. None changes the tax sign in the create flow. TaxFields.tsx and useTaxAmount.ts were last changed in earlier releases already on production.

    Why reverting won't help. A revert leaves the create flow unchanged and brings back the details-page inconsistency the PR fixed.

    Where to fix it (follow-up). Change these together so the sign is consistent from calculation to display:

    1. useTaxAmount.ts:77 and line 83: use the signed amount for expense reports. Keep Math.abs for IOU/P2P requests.
    2. DynamicIOURequestStepTaxRatePage.tsx:159: pass the signed amount to the tax calculation.
    3. TaxFields.tsx:70: display the tax with its sign.
    4. useConfirmationValidation.ts:299 and DynamicIOURequestStepTaxAmountPage.tsx:181: let validation and the tax input accept a negative tax.

    Limits. This is based on code analysis. I did not reproduce it on staging or production.

  8. bernhardoj commented on Oct 10, 2026

    @bernhardoj
    Contributor

    #102175 did not cause this. The create-expense flow has always shown a positive tax for a negative amount, and production behaves the same way.

    True.
    Related to #103663

  9. jloa-dev commented on Oct 10, 2026

    @jloa-dev

    Proposal

    Please re-state the problem that the issue is addressing

    Expense - Tax amount field is not negative when amount is negative during manual expense creation.

    What is the root cause of that problem?

    In the manual expense creation flow:

    1. In \DynamicIOURequestStepTaxRatePage.tsx:159, when selecting a tax rate, tax calculation calls:
      \getTaxAmount(policy, currentTransaction, taxes.code, getAmount(currentTransaction, false, true), decimals)
      Passing \isFromTrackedExpense = true\ to \getAmount\ causes \getAmount\ to invert the draft transaction amount (\�mount ? -amount : 0), flipping the user's negative amount -1000\ into +1000. This computes a positive tax amount +48\ which is saved into the draft transaction via \setMoneyRequestTaxRateValues.
    2. In \useTaxAmount.ts:77\ and line 83, \ axableAmount\ and \ axAmount\ use \Math.abs(...)\ unconditionally (\Math.abs(transaction?.amount ?? 0)\ and \Math.abs(transaction?.taxAmount ?? 0)), which forces any computed tax amount to be positive. \TaxController.tsx\ then synchronizes and overwrites \ ransaction.taxAmount\ with this positive value.
    3. In \TaxFields.tsx:70, the displayed tax amount was read via \getTaxAmount(transactionForHelpers, false)\ which calls
      ormalizeTaxAmountSign(..., false)\ returning \Math.abs(...), stripping the negative sign from display. Additionally, \NumberWithSymbolForm\ was missing \�llowNegativeInput\ for negative expenses.
    4. In \DynamicIOURequestStepTaxAmountPage.tsx:181, \�mount\ was passed as \Math.abs(transactionDetails?.taxAmount ?? 0), \getTaxAmount\ did not receive \�llowNegative\ and \disableOppositeConversion, and \�llowFlippingAmount\ was not passed to \MoneyRequestAmountForm.

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

    1. In \src/pages/iou/request/step/DynamicIOURequestStepTaxRatePage.tsx:
      Derive the signed transaction amount respecting negative expenses and the create flow:
      \\ ypescript
      const isCreateAction = action === CONST.IOU.ACTION.CREATE;
      const isSubmitAction = action === CONST.IOU.ACTION.SUBMIT;
      const isSubmitType = iouType === CONST.IOU.TYPE.SUBMIT;
      const allowNegative = shouldEnableNegative(report, policy, iouType, currentTransaction?.participants);
      const disableOppositeConversion = isCreateAction || (isSubmitType && isSubmitAction);
      const transactionAmount = getAmount(currentTransaction, isExpenseReport(report), currentTransaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID, allowNegative, disableOppositeConversion);
      const taxAmount = getTaxAmount(policy, currentTransaction, taxes.code, transactionAmount, decimals);
      \\
    2. In \src/components/MoneyRequestConfirmationList/hooks/useTaxAmount.ts:
      Preserve the signed amount when computing \ axableAmount\ and \ axAmount\ instead of wrapping with \Math.abs:
      \\ ypescript
      const taxableAmount = isDistanceRequest ? DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, taxableDistance) : (transaction?.amount ?? 0);
      ...
      const taxAmount = isMovingTransactionFromTrackExpense && transaction?.taxAmount ? (transaction?.taxAmount ?? 0) : calculateTaxAmount(taxPercentage, taxableAmount, taxDecimals);
      \\
    3. In \src/components/MoneyRequestConfirmationList/sections/TaxFields.tsx:
      Read \ axAmount\ directly from \ axSlice?.taxAmount ?? 0, and pass \�llowNegativeInput={(taxSlice?.amount ?? 0) < 0}\ to \NumberWithSymbolForm.
    4. In \src/pages/iou/request/step/DynamicIOURequestStepTaxAmountPage.tsx:
      Update \getTaxAmount\ to accept \isExpenseReport, \�llowNegative, and \disableOppositeConversion, and pass \�mount={transactionDetails?.taxAmount ?? 0}, the signed \ axAmount, and \�llowFlippingAmount={allowNegative}\ to \MoneyRequestAmountForm.

    Tested branch pre-coded with unit test coverage on:
    https://github.com/jloa-dev/App/tree/fix/103664-create-negative-tax-amount

  10. jloa-dev commented on Oct 10, 2026

    @jloa-dev

    Contributor details
    Your Expensify account email: jloa.dev@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0163955a2ba22190aa

  11. melvin-bot commented on Oct 10, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  12. cristipaval commented on Oct 12, 2026

    @cristipaval
    Contributor

    demoting, per #103664 (comment)

  13. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Oct 12, 2026
  14. grgia commented on Oct 15, 2026

    @grgia
    Contributor

    Reverted

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions