Skip to content

[HOLD E/E #601592] Distance - Change waypoint before create expense, Tax amount change to 0 #79861

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: v9.3.4-0
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-3029/folder/13176868/41237331/1131713395
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Win 11/Chrome
App Component: Money Requests

Action Performed:

Precondition: Track tax in distance expenses is enabled, set default tax rate is over 0%

  1. Open https://staging.new.expensify.com
  2. Navigate to workspace chat and create Track distance
  3. Enter address for two waypoints and click Next
  4. Click on Distance row
  5. Change another address for Stop waypoint and Save
  6. Observe Tax amount
  7. Click on Create expense
  8. Click on expense preview for go to detail page
  9. Waiting page loading completed and observe tax amount

Expected Result:

After created expense, tax amount should display correctly

Actual Result:

After created expense, tax amount is changed to 0

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Activity

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

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (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. yatin-italy commented on Jan 19, 2026

    @yatin-italy

    Proposal

    Restate the problem this issue is trying to solve.
    Changing a distance waypoint before creating the expense recalculates amount/merchant but leaves draft taxAmount stale (often 0), so the created expense is saved with zero tax despite policy distance tax being enabled.

    What is the root cause of that problem?
    getUpdatedTransaction recalculates distance amount. It does not recalculate tax. The draft tax value stays old. That stale value is sent to the backend.

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

    • Add an invariant.
    • Distance draft tax must always match the current route distance and policy tax defaults.
    • Apply it when waypoints change and when mileage rate changes.

    Make the change in getUpdatedTransaction.

    • Use one local helper.
    • Call it in two places.
    • Do not change the pending-route path.

    File src/libs/TransactionUtils/index.ts in getUpdatedTransaction:

    // Add local helper near top of getUpdatedTransaction
    const applyDistanceTax = (txn: Transaction, meters: number, currencyCode: string | undefined) => {
        if (!isDistanceRequest(txn) || !policy) {
            return;
        }
        const customUnitRateID = getRateID(txn);
        const defaultTaxCode = getDefaultTaxCode(policy, txn, currencyCode) ?? '';
        const taxCode = txn.taxCode ?? defaultTaxCode;
        const taxableAmount = DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, meters);
        const taxPercentage = getTaxValue(policy, txn, taxCode) ?? '';
        const taxAmount = calculateTaxAmount(taxPercentage, taxableAmount, currencyCode ?? CONST.CURRENCY.USD);
        const taxAmountInSmallestUnits = convertToBackendAmount(Number.parseFloat(taxAmount.toString()));
        txn.taxAmount = isFromExpenseReport ? -taxAmountInSmallestUnits : taxAmountInSmallestUnits;
    };

    Waypoint change branch.

    • Only when route geometry exists.
    • Leave pending route logic as is.
    if (Object.hasOwn(transactionChanges, 'waypoints')) {
        ...
        if (transactionChanges.routes?.route0?.geometry?.coordinates) {
            ...
            updatedTransaction.amount = updatedAmount;
            updatedTransaction.modifiedAmount = updatedAmount;
            updatedTransaction.modifiedMerchant = updatedMerchant;
            applyDistanceTax(updatedTransaction, distanceInMeters, transaction.currency);
        }
    }

    Mileage rate change branch.

    • Reuse the helper after amount and merchant update.
    if (Object.hasOwn(transactionChanges, 'customUnitRateID') || Object.hasOwn(transactionChanges, 'rate')) {
        ...
        if (!isFetchingWaypointsFromServer(transaction)) {
            ...
            updatedTransaction.modifiedCurrency = updatedCurrency;
            applyDistanceTax(updatedTransaction, distanceInMeters, updatedCurrency);
        }
    }

    This keeps tax correct for both waypoint edits and rate edits.

    • It avoids writing tax when the route is not ready.
    • The change is small and local.

    What alternative solutions did you explore? (Optional)
    -Recomputing tax in UI layers (It spreads logic and breaks the shared invariant).

  4. annaweber830 commented on Jan 20, 2026

    @annaweber830
    Contributor

    Hi @mallenexpensify, this seems like a backend issue.

  5. mallenexpensify commented on Jan 21, 2026

    @mallenexpensify
    Contributor

    Thanks @annaweber830 , checking here

  6. self-assigned this
    on Jan 21, 2026
  7. added
    InternalRequires API changes or must be handled by Expensify staff
    on Jan 21, 2026
  8. c3024 commented on Jan 24, 2026

    @c3024
    Contributor

    I will address the PR review suggestions on Monday.

  9. added
    ReviewingHas a PR in review
    and removed on Jan 26, 2026
  10. 17 remaining items

  11. mallenexpensify commented on Mar 25, 2026

    @mallenexpensify
    Contributor
  12. c3024 commented on Mar 31, 2026

    @c3024
    Contributor

    This should still be held on #79867 because the default values for taxReclaimablePercentage are different on the frontend (1) and the backend (0).

    We should change the frontend value to 0 which should be handled in the App PR for the issue #79867.

  13. chuckdries commented on Mar 31, 2026

    @chuckdries
    Contributor

    Backend PR has been released to production! @c3024 could you check and see that it now behaves as you expect?

  14. c3024 commented on Apr 9, 2026

    @c3024
    Contributor

    With this frontend PR now deployed, this issue should be fixed. The issue was caused by a mismatch where the frontend set a tax, while the backend set it to zero when no taxClaimablePercentage was provided.

    I’ve requested QA to retest.

  15. m-natarajan commented on Apr 9, 2026

    @m-natarajan

    Tax amount not changes at all. It stays 0, Chrome / v9.3.55-0

    bandicam.2026-04-09.14-21-22-268.mp4
  16. m-natarajan commented on Apr 9, 2026

    @m-natarajan

    Production behavior for this

    bandicam.2026-04-09.14-59-00-504.mp4
  17. c3024 commented on Apr 20, 2026

    @c3024
    Contributor

    The tax value stays zero throughout, even in production. This is expected behavior with PR, which sets the default value for taxReclaimablePercentage to zero.

    Asked QA to retest.

  18. IuliiaHerets commented on Apr 20, 2026

    @IuliiaHerets

    Windows 11 / Chrome
    v9.3.60-17
    can't repro, tax amount displayed $0.0 on confirmation page before and after changing the stop waypoint, and after creating the expense

    tax.rate.mp4

    can't repro on web v9.3.59-4 Prod

    prod.1.mp4

    Same on Android and iOS (stg and prod)

    Screenrecorder-2026-04-20-10-13-22-638.mp4
    prod.ios.MP4
    tax.ios.MP4
    Screenrecorder-2026-04-20-09-49-50-647.mp4
  19. c3024 commented on Apr 20, 2026

    @c3024
    Contributor

    Closing as QA too confirmed this is not repro.

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.InternalRequires API changes or must be handled by Expensify staffWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions