Skip to content

[$250] Report - Tax rate selected manually is not retained on report if a rule was created before. #83175

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?: 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: #81514
Email or phone of affected tester (no customers): ibellicotest+2250@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has at least one workspace with rules enabled.
Prerequisite 2: "Taxes" enabled and at least two taxes different from default available.

  1. Open the Expensify app.
  2. Navigate to "Workspaces" > "Rules" > "Add Merchant Rule"
  3. In "For expenses with", add any merchant.
  4. In "Apply these updates", add any category, a description and a tax that is different from the default one.
  5. Save the rule.
  6. Navigate to workspace chat.
  7. Start a manual expense creation flow.
  8. Add an amount and tap on "Next"
  9. Add the same merchant from step 3.
  10. Select a category different from the one on created rule and also a different description.
  11. Navigate to "Tax" field and select a rate that is different as the one selected on the created rule, and also different from the default one.
  12. Finish the expense creation flow.
  13. Open the report of the just created expense.
  14. Note that "Category" and "Description" fields, show the information added manually while creating expense.
  15. Note that tax rate selected manually, was not retained.

Expected Result:

Created rules should not override the fields that were selected manually by the user while creating expense.

Actual Result:

Tax rate selected manually while creating an expense, is not retained if a rule was created before.

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

Issue OwnerCurrent Issue Owner: @ChavdaSachin
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022025806224289136176
  • Upwork Job ID: 2025806224289136176
  • Last Price Increase: 2026-02-23

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Feb 23, 2026

    @melvin-bot

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

  4. melvin-bot commented on Feb 23, 2026

    @melvin-bot

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

  5. github-actions commented on Feb 23, 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.
  6. OSBotify commented on Feb 23, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Backend bug
    Causing PR: Cannot be determined - this appears to be a backend issue, not a frontend (App) bug
    Related Feature: Merchant Rules (enabled via #82438)

    Recommendation: REMOVE DeployBlockerCash LABEL

    The tax rate override issue is caused by backend logic applying merchant coding rules incorrectly, not by any App PR.

    Labels: Removing DeployBlockerCash label. This does NOT block the App deploy. Keeping DeployBlocker label as this blocks the backend/Web deploy.

    Detailed Analysis

    Evidence

    What happens:

    1. User creates a merchant coding rule with specific category, description, and tax rate
    2. User manually creates an expense with the SAME merchant but DIFFERENT category, description, and tax rate
    3. After expense creation completes, the tax rate is overridden by the rule
    4. However, category and description are NOT overridden (remain as manually selected)

    Why this indicates a backend bug:

    • Merchant rules are applied by the backend after expense submission, not by frontend code
    • I extensively searched the App codebase and found NO logic that applies coding rules to transactions
    • The issue reports the tax is "not retained" AFTER completing the flow, indicating server-side processing
    • The selective override (tax only, not category/description) suggests backend rule application logic is incorrect

    Verification

    Frontend code checked:

    • src/libs/actions/IOU/index.ts - No merchant rule application logic
    • src/libs/ExpenseRuleUtils.ts - Only formatting utilities, no application logic
    • src/pages/iou/request/step/IOURequestStepConfirmation.tsx - Uses transaction tax values as-is
    • setMoneyRequestTaxRate() function - Simple setter, no rule checking

    Merchant Rules PRs:

    None of these App PRs contain logic for APPLYING merchant rules to expenses during creation.

    Root Cause

    Merchant coding rules are a backend feature. The backend applies these rules when processing expense submissions. The bug is that the backend is:

    1. Correctly NOT overriding category and description when manually selected
    2. INCORRECTLY overriding tax rate even when manually selected

    This inconsistency in the backend rule application logic cannot be fixed in the App repository.

    Why This Doesnt Block App Deploy

    • No App PR caused this issue
    • The bug exists in backend code, not frontend
    • Reverting any App PR would not fix the issue
    • The fix must be made in the backend/API codebase
  7. MelvinBot commented on Feb 23, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When a workspace has a merchant rule configured with a specific tax rate, and a user manually creates an expense with that merchant but selects a different tax rate, the manually selected tax rate is not retained on the report. The merchant rule's tax rate overrides the user's manual selection. Category and description fields that are manually set by the user are correctly preserved.

    What is the root cause of that problem?

    Merchant rules (both personal expense rules from NVP_EXPENSE_RULES and workspace coding rules from policy.rules.codingRules) are applied server-side after the REQUEST_MONEY API call. The front-end sends all transaction fields (including taxCode and taxAmount) to the backend, but there is no mechanism to indicate which fields were manually set by the user.

    Key evidence from the codebase:

    • setMoneyRequestMerchant() at src/libs/actions/IOU/index.ts:1445 simply writes the merchant to the draft with zero rule matching — unlike setMoneyRequestCategory() (line 1476) which applies category-based tax rules client-side.
    • setMoneyRequestTaxRate() at src/libs/actions/IOU/index.ts:12338 just merges {taxCode} into the draft — no "user-modified" flag is set.
    • RequestMoneyParams at src/libs/API/parameters/RequestMoneyParams.ts:24-26 sends taxCode and taxAmount as plain values with no provenance metadata.
    • The Transaction type at src/types/onyx/Transaction.ts has no field like userModifiedFields or manuallySetTax.

    When the backend receives the request, it matches the merchant against coding rules (policy.rules.codingRules filters, defined at src/types/onyx/Policy.ts:1720-1756) and/or personal expense rules (NVP_EXPENSE_RULES, defined at src/types/onyx/ExpenseRule.ts). Because the backend cannot distinguish between a user-selected tax and a default tax, it unconditionally applies the rule's tax rate, overwriting the user's manual selection. The server then pushes the updated transaction data back via Onyx updates, replacing the optimistic values.

    Category and description appear to be preserved because the backend likely has selective override logic for those fields (checking whether the user-provided value differs from the default), but applies the tax override unconditionally. This selective behavior cannot be confirmed without backend code access, but the front-end evidence rules out a client-side cause.

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

    There are two approaches, depending on whether we fix this client-side or server-side:

    Option A (Recommended — Client-side): Add a userModifiedFields property to the transaction draft (or a specific isTaxManuallySet flag). When the user explicitly selects a tax rate via IOURequestStepTaxRatePage, set this flag on the draft. Pass it through to the RequestMoneyParams API call so the backend can skip the rule's tax override when the user made a manual selection.

    Option B (Server-side): Modify the backend rule application logic to compare the incoming taxCode against the policy's default tax. If they differ, assume the user manually chose it and skip the rule override for tax. This is simpler but less reliable (what if the user intentionally chose the default?).

    The fix should ensure that:

    1. If a user explicitly selects a tax rate, that selection is preserved regardless of merchant rules.
    2. If the user does NOT manually change the tax (leaving the default), the merchant rule's tax should still apply as expected.

    What alternative solutions did you explore? (Optional)

    A purely front-end solution was considered where the merchant rule is applied client-side (similar to how setMoneyRequestCategory applies category-based tax rules), with logic to skip application if the user already manually set the tax. However, since merchant rule application involves matching against server-side data (coding rules and personal expense rules), this would require duplicating backend logic and is less maintainable.


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

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 23, 2026
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 23, 2026
  10. melvin-bot commented on Feb 23, 2026

    @melvin-bot

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

  11. changed the title [-]Report - Tax rate selected manually is not retained on report if a rule was created before.[/-] [+][$250] Report - Tax rate selected manually is not retained on report if a rule was created before.[/+] on Feb 23, 2026
  12. melvin-bot commented on Feb 23, 2026

    @melvin-bot
  13. himal250692 commented on Feb 23, 2026

    @himal250692

    What problem are we trying to solve?
    When a workspace merchant rule includes a tax rate, and a user manually selects a different tax rate while creating an expense for that same merchant, the user’s manual tax selection is not retained.
    Merchant rules should not override fields explicitly chosen by the user during expense creation.

    Why is this happening?
    The frontend currently sends taxCode/taxAmount as plain values in RequestMoney, but does not send whether tax was manually edited by the user.
    When the backend applies merchant/coding rules after REQUEST_MONEY, it cannot distinguish:

    “default tax still untouched” vs

    “user intentionally selected this tax”

    So tax can be overwritten by rule application.

    Proposed solution (recommended)
    Add explicit “user-modified” provenance for tax and honor it during rule application.

    Track tax manual edit in the draft transaction (e.g. userModifiedFields.taxCode = true, or isTaxManuallySet = true) when user changes tax in IOURequestStepTaxRatePage.

    Include that flag in RequestMoneyParams.
    On backend rule application, skip tax override if manual-tax flag is true.
    Keep current behavior (rule may apply tax) when user did not manually edit tax.
    This aligns tax behavior with the expectation already seen for other manually-entered fields like category/description.

    Why this is the best option
    Deterministic and explicit; no inference from value comparisons.
    Avoids false assumptions (e.g., user intentionally choosing default tax).
    Scales to other fields if we later need similar “manual override wins” behavior.

  14. kgshriramm commented on Feb 23, 2026

    @kgshriramm

    Proposal

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

    When a workspace has a merchant rule configured with a specific tax rate, and a user manually creates an expense with that merchant but selects a different tax rate, the manually selected tax rate is not retained. Instead, the merchant rule’s tax rate overrides the user’s selection
    Although category and description fields respect manual changes, tax does not. This leads to incorrect tax values being applied even when the user explicitly selects a different rate.

    What is the root cause of that problem?

    The frontend always sends taxCode and taxAmount to the backend in RequestMoney, TrackExpense, and related API calls. However there is no way to indicate whether the tax was
    Automatically populated from policy defaults, or
    Explicitly selected by the user in the Tax Rate step

    Because there is no provenance tracking, the backend applies merchant rule logic unconditionally and overrides the tax value
    The core issue is that user intent is not explicitly encoded in the transaction data

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

    The most scalable and explicit solution is to introduce a taxCodeManuallySet flag to track whether the tax was explicitly chosen by the user
    This allows the backend to preserve manual selections while continuing to apply merchant rules when the tax was not modified by the user.

    1. Add taxCodeManuallySet flag to Data Types

    Add a new optional boolean property to track whether the tax was manually selected.
    This ensures the transaction object and API payload can carry user intent explicitly.

    [MODIFY] src/types/onyx/Transaction.ts taxCodeManuallySet?: boolean;
    [MODIFY] src/libs/API/parameters/TrackExpenseParams.ts taxCodeManuallySet?: boolean;
    [MODIFY] src/libs/API/parameters/RequestMoneyParams.ts taxCodeManuallySet?: boolean;
    [MODIFY] src/libs/API/parameters/CreateDistanceRequestParams.ts taxCodeManuallySet?: boolean;

    Explanation:
    Making this field optional preserves backward compatibility and ensures existing flows are not impacted.

    1. Set the flag when Tax is manually picked

    We update the tax selection flow so that whenever a user explicitly chooses a tax rate, the draft transaction records that action

    [MODIFY] src/libs/actions/IOU/index.ts

    Update setMoneyRequestTaxRate to accept a new argument:

    function setMoneyRequestTaxRate(
        transactionID: string,
        taxCode: string | null,
        isDraft = true,
        isManuallySet = false
    ) {
        Onyx.merge(
            `${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
            {
                taxCode,
                ...(isManuallySet ? {taxCodeManuallySet: true} : {}),
            },
        );
    }

    Explanation:
    This ensures that when tax is explicitly selected, we persist that user intent into the draft transaction stored in Onyx
    [MODIFY] src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx

    Call the updated function with isManuallySet = true:

    const updateTaxRates = (taxes: TaxRate) => {
        if (isEditing) {
            // existing logic
        } else {
            setMoneyRequestTaxRate(transactionID, taxes.code, true, true);
            // ...
        }
    };

    Explanation:
    This ensures the flag is only set when the user actively selects a tax rate, not when tax is auto populated

    1. Pass the flag to the API Payload

    When constructing API parameters for RequestMoney, TrackExpense, and CreateDistanceRequest, propagate the flag to the backend.
    [MODIFY] src/libs/actions/IOU/index.ts

    Inside getTrackExpenseInformation() and getMoneyRequestInformation():

    const transactionParams: TrackExpenseTransactionParams = {
        // ...
        taxCodeManuallySet: item.taxCodeManuallySet,
    };

    Explanation:
    This ensures the backend receives explicit information about whether the tax was manually set
    The backend can then skip merchant rule tax overrides when taxCodeManuallySet is true, while preserving existing rule behavior for non modified taxes.

    What alternative solutions did you explore? (Optional)

    An alternative approach would be to omit sending taxCode and taxAmount when they match the policy default. This would allow the backend to infer user intent based on presence or absence of values
    However, this approach relies on implicit inference and may introduce ambiguity in cases where a user intentionally selects the default tax
    The proposed taxCodeManuallySet flag explicitly encodes user intent, making the behavior scalable, and easier to maintain

  15. nabi-ebrahimi commented on Feb 23, 2026

    @nabi-ebrahimi

    Proposal

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

    Report - Tax rate selected manually is not retained on report if a rule was created before.

    What is the root cause of that problem?

    The create flows submit taxCode/taxAmount as plain values, but there is no durable intent signal that the tax was manually selected by the user.

    setMoneyRequestTaxRate() only merges {taxCode} (no user-intent metadata):

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

    Lines 12338 to 12339 in 337f2a5

    function setMoneyRequestTaxRate(transactionID: string, taxCode: string | null, isDraft = true) {
    Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {taxCode});

    RequestMoneyParams contains taxCode/taxAmount only:
    taxCode: string;
    taxAmount: number;

    TrackExpenseParams contains taxCode/taxAmount only:
    taxCode: string;
    taxAmount: number;

    CreateDistanceRequestParams contains taxCode/taxAmount only:
    taxCode?: string;
    taxAmount?: number;

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

    Mark tax as manually selected only from explicit user action in tax-rate step.
    Carry this flag through create submissions.
    After create command settles, compare server tax vs user-selected tax.
    If mismatch, use existing update API (UPDATE_MONEY_REQUEST_TAX_RATE) to restore user-selected tax.
    Keep retries bounded and delayed until optimistic data settles.
    Code diffs (short description + related git diff) for every changed file:

    1. src/libs/actions/IOU/index.ts
      Adds manual-tax reconciliation helper, threads manual-tax flag through create flows, and updates tax setter to persist manual flag.
    index d37630cc1b5..095b89c7006 100644
    --- a/src/libs/actions/IOU/index.ts
    +++ b/src/libs/actions/IOU/index.ts
    @@ -38,7 +38,7 @@ import type {
         UpdateMoneyRequestParams,
     } from '@libs/API/parameters';
     import {WRITE_COMMANDS} from '@libs/API/types';
    -import {convertAmountToDisplayString, convertToDisplayString, convertToFrontendAmountAsString} from '@libs/CurrencyUtils';
    +import {convertAmountToDisplayString, convertToBackendAmount, convertToDisplayString, convertToFrontendAmountAsString, getCurrencyDecimals} from '@libs/CurrencyUtils';
     import DateUtils from '@libs/DateUtils';
     import DistanceRequestUtils from '@libs/DistanceRequestUtils';
     import {getMicroSecondOnyxErrorObject, getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
    @@ -201,12 +201,14 @@ import {startSpan} from '@libs/telemetry/activeSpans';
     import {
         allHavePendingRTERViolation,
         buildOptimisticTransaction,
    +    calculateTaxAmount,
         getAmount,
         getCategoryTaxCodeAndAmount,
         getClearedPendingFields,
         getCurrency,
         getDistanceInMeters,
         getMerchant,
    +    getTaxValue,
         getUpdatedTransaction,
         hasAnyTransactionWithoutRTERViolation,
         hasDuplicateTransactions,
    @@ -282,6 +284,7 @@ type BaseTransactionParams = {
         reimbursable?: boolean;
         customUnitRateID?: string;
         isFromGlobalCreate?: boolean;
    +    isTaxCodeManuallySelected?: boolean;
     };
    @@ -729,6 +732,7 @@ type TrackExpenseTransactionParams = {
         odometerEnd?: number;
         isFromGlobalCreate?: boolean;
         gpsCoordinates?: string;
    +    isTaxCodeManuallySelected?: boolean;
     };
    @@ -775,6 +779,7 @@ type GetTrackExpenseInformationTransactionParams = {
         odometerStart?: number;
         odometerEnd?: number;
         gpsCoordinates?: string;
    +    isTaxCodeManuallySelected?: boolean;
     };
    @@ -893,6 +898,24 @@ type PayMoneyRequestFunctionParams = {
         betas: OnyxEntry<OnyxTypes.Beta[]>;
     };
     
    +type ManualTaxReconciliationParams = {
    +    transactionID: string | undefined;
    +    transactionThreadReportID: string | undefined;
    +    iouReportID: string | undefined;
    +    desiredTaxCode: string;
    +    shouldReconcile: boolean;
    +    policy: OnyxEntry<OnyxTypes.Policy>;
    +    policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>;
    +    policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>;
    +    currentUserAccountIDParam: number;
    +    currentUserEmailParam: string;
    +    isASAPSubmitBetaEnabled: boolean;
    +    parentReportNextStep: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
    +};
    +
    +const MANUAL_TAX_RECONCILIATION_DELAY_MS = 1200;
    +const MANUAL_TAX_RECONCILIATION_MAX_ATTEMPTS = 5;
    +
     let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
    @@ -1165,6 +1188,59 @@ function handleNavigateAfterExpenseCreate({
         });
     }
     
    +function reconcileManualTaxSelection(params: ManualTaxReconciliationParams, attempt = 0) {
    +    const {transactionID, shouldReconcile, desiredTaxCode} = params;
    +    if (!shouldReconcile || !transactionID || !desiredTaxCode) {
    +        return;
    +    }
    +
    +    setTimeout(
    +        () => {
    +            const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
    +
    +            // Wait until optimistic creation settles before comparing server-backed values.
    +            if (!transaction || transaction.pendingAction || transaction.isLoading) {
    +                if (attempt < MANUAL_TAX_RECONCILIATION_MAX_ATTEMPTS - 1) {
    +                    reconcileManualTaxSelection(params, attempt + 1);
    +                }
    +                return;
    +            }
    +
    +            if (transaction.taxCode === desiredTaxCode) {
    +                return;
    +            }
    +
    +            const parentReport = params.iouReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${params.iouReportID}`] : undefined;
    +            if (!parentReport) {
    +                return;
    +            }
    +
    +            const transactionThreadReport = params.transactionThreadReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${params.transactionThreadReportID}`] : undefined;
    +            const transactionAmount = getAmount(transaction, false, true);
    +            const taxValue = getTaxValue(params.policy, transaction, desiredTaxCode) ?? '';
    +            const decimals = getCurrencyDecimals(getCurrency(transaction));
    +            const taxAmount = convertToBackendAmount(calculateTaxAmount(taxValue, transactionAmount, decimals));
    +
    +            updateMoneyRequestTaxRate({
    +                transactionID,
    +                transactionThreadReport,
    +                parentReport,
    +                taxCode: desiredTaxCode,
    +                taxAmount,
    +                taxValue,
    +                policy: params.policy,
    +                policyTagList: params.policyTagList,
    +                policyCategories: params.policyCategories,
    +                currentUserAccountIDParam: params.currentUserAccountIDParam,
    +                currentUserEmailParam: params.currentUserEmailParam,
    +                isASAPSubmitBetaEnabled: params.isASAPSubmitBetaEnabled,
    +                parentReportNextStep: params.parentReportNextStep,
    +            });
    +        },
    +        MANUAL_TAX_RECONCILIATION_DELAY_MS * (attempt + 1),
    +    );
    +}
    @@ -6554,6 +6630,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
             personalDetails,
         } = requestMoneyInformation;
         const {payeeAccountID} = participantParams;
    +    const {policy, policyCategories, policyTagList} = policyParams;
    @@ -6583,6 +6660,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
             rate,
             unit,
             isFromGlobalCreate,
    +        isTaxCodeManuallySelected,
         } = transactionParams;
    @@ -6776,6 +6854,21 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
                 };
                 // eslint-disable-next-line rulesdir/no-multiple-api-calls
                 API.write(WRITE_COMMANDS.REQUEST_MONEY, parameters, onyxData);
    +
    +            reconcileManualTaxSelection({
    +                transactionID: transaction.transactionID,
    +                transactionThreadReportID,
    +                iouReportID: iouReport.reportID,
    +                desiredTaxCode: taxCode,
    +                shouldReconcile: !!isTaxCodeManuallySelected,
    +                policy,
    +                policyTagList,
    +                policyCategories,
    +                currentUserAccountIDParam,
    +                currentUserEmailParam,
    +                isASAPSubmitBetaEnabled,
    +                parentReportNextStep: undefined,
    +            });
             }
         }
    @@ -7375,6 +7468,7 @@ function trackExpense(params: CreateTrackExpenseParams) {
             odometerEnd,
             isFromGlobalCreate,
             gpsCoordinates,
    +        isTaxCodeManuallySelected,
         } = transactionData;
    @@ -7407,6 +7501,7 @@ function trackExpense(params: CreateTrackExpenseParams) {
                 tag,
                 taxCode,
                 taxAmount,
    +            isTaxCodeManuallySelected,
                 billable,
                 reimbursable,
                 validWaypoints,
    @@ -7663,6 +7758,21 @@ function trackExpense(params: CreateTrackExpenseParams) {
                 }
     
                 API.write(WRITE_COMMANDS.TRACK_EXPENSE, parameters, onyxData);
    +
    +            reconcileManualTaxSelection({
    +                transactionID: transaction?.transactionID,
    +                transactionThreadReportID,
    +                iouReportID: iouReport?.reportID,
    +                desiredTaxCode: taxCode,
    +                shouldReconcile: !!isTaxCodeManuallySelected,
    +                policy,
    +                policyTagList,
    +                policyCategories,
    +                currentUserAccountIDParam,
    +                currentUserEmailParam,
    +                isASAPSubmitBetaEnabled,
    +                parentReportNextStep: undefined,
    +            });
             }
         }
    @@ -8300,6 +8410,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
             odometerEnd,
             isFromGlobalCreate,
             gpsCoordinates,
    +        isTaxCodeManuallySelected,
         } = transactionParams;
    @@ -8316,6 +8427,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
             : receipt;
     
         let parameters: CreateDistanceRequestParams;
    +    let manualTaxReconciliationParams: ManualTaxReconciliationParams | undefined;
    @@ -8421,6 +8533,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
                     tag,
                     taxCode,
                     taxAmount,
    +                isTaxCodeManuallySelected,
                     billable,
                     reimbursable,
                     attendees,
    @@ -8490,6 +8603,21 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
                 attendees: attendees ? JSON.stringify(attendees) : undefined,
                 gpsCoordinates,
             };
    +
    +        manualTaxReconciliationParams = {
    +            transactionID: transaction.transactionID,
    +            transactionThreadReportID,
    +            iouReportID: iouReport.reportID,
    +            desiredTaxCode: taxCode ?? '',
    +            shouldReconcile: !!isTaxCodeManuallySelected,
    +            policy,
    +            policyTagList,
    +            policyCategories,
    +            currentUserAccountIDParam: currentUserAccountID,
    +            currentUserEmailParam: currentUserLogin,
    +            isASAPSubmitBetaEnabled,
    +            parentReportNextStep: undefined,
    +        };
         }
    @@ -8502,6 +8630,9 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
         playSound(SOUNDS.DONE);
     
         API.write(WRITE_COMMANDS.CREATE_DISTANCE_REQUEST, parameters, onyxData);
    +    if (manualTaxReconciliationParams) {
    +        reconcileManualTaxSelection(manualTaxReconciliationParams);
    +    }
    @@ -12335,8 +12466,8 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On
         });
     }
     
    -function setMoneyRequestTaxRate(transactionID: string, taxCode: string | null, isDraft = true) {
    -    Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {taxCode});
    +function setMoneyRequestTaxRate(transactionID: string, taxCode: string | null, isDraft = true, isTaxCodeManuallySelected = false) {
    +    Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {taxCode, isTaxCodeManuallySelected});
     }
    1. src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx
      Marks tax choice as manual only when user explicitly picks a tax.
    index d6a0b9b618e..026aa36e3b7 100644
    --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx
    +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx
    @@ -117,7 +117,7 @@ function IOURequestStepTaxRatePage({
                 return;
             }
             const amountInSmallestCurrencyUnits = convertToBackendAmount(taxAmount);
    -        setMoneyRequestTaxRate(currentTransaction?.transactionID, taxes?.code ?? '');
    +        setMoneyRequestTaxRate(currentTransaction?.transactionID, taxes?.code ?? '', true, true);
             setMoneyRequestTaxAmount(currentTransaction.transactionID, amountInSmallestCurrencyUnits);
     
             navigateBack();
    1. src/pages/iou/request/step/IOURequestStepConfirmation.tsx
      Passes manual-tax marker into submission payload builders for request/track/distance.
    index 959f05a4f9a..929c733f8be 100644
    --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx
    +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx
    @@ -612,6 +612,7 @@ function IOURequestStepConfirmation({
                             tag: item.tag,
                             taxCode: transactionTaxCode,
                             taxAmount: transactionTaxAmount,
    +                        isTaxCodeManuallySelected: item.isTaxCodeManuallySelected,
                             billable: item.billable,
                             reimbursable: item.reimbursable,
                             actionableWhisperReportActionID: item.actionableWhisperReportActionID,
    @@ -813,6 +814,7 @@ function IOURequestStepConfirmation({
                             tag: item.tag,
                             taxCode: transactionTaxCode,
                             taxAmount: transactionTaxAmount,
    +                        isTaxCodeManuallySelected: item.isTaxCodeManuallySelected,
                             billable: item.billable,
                             reimbursable: item.reimbursable,
                             gpsPoint,
    @@ -902,6 +904,7 @@ function IOURequestStepConfirmation({
                         tag: transaction.tag,
                         taxCode: transactionTaxCode,
                         taxAmount: transactionTaxAmount,
    +                    isTaxCodeManuallySelected: transaction.isTaxCodeManuallySelected,
                         customUnitRateID,
                         splitShares: transaction.splitShares,
                         validWaypoints: getValidWaypoints(transaction.comment?.waypoints, true, isGPSDistanceRequest),
    1. src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts
      Adds local transaction field to store explicit manual tax intent.
    index 92cd69b7cae..2b81760024f 100644
    --- a/src/types/onyx/Transaction.ts
    +++ b/src/types/onyx/Transaction.ts
    @@ -452,6 +452,9 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback<
             /** The transaction tax code */
             taxCode?: string;
     
    +        /** Whether the current tax code was explicitly selected by the user during request creation */
    +        isTaxCodeManuallySelected?: boolean;
    +
             /** The transaction tax value */
             taxValue?: string | undefined;
    1. src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts
      Updates debug validators/switch exhaustiveness for new transaction field.
    index d5d82cbd816..4f7f23cb94a 100644
    --- a/src/libs/DebugUtils.ts
    +++ b/src/libs/DebugUtils.ts
    @@ -980,6 +980,7 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string)
             case 'isFromGlobalCreate':
             case 'isFromFloatingActionButton':
             case 'hasEReceipt':
    +        case 'isTaxCodeManuallySelected':
             case 'shouldShowOriginalAmount':
             case 'managedCard':
                 return validateBoolean(value);
    @@ -1068,6 +1069,7 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string)
                         convertedAmount: CONST.RED_BRICK_ROAD_PENDING_ACTION,
                         convertedTaxAmount: CONST.RED_BRICK_ROAD_PENDING_ACTION,
                         taxCode: CONST.RED_BRICK_ROAD_PENDING_ACTION,
    +                    isTaxCodeManuallySelected: CONST.RED_BRICK_ROAD_PENDING_ACTION,
                         billable: CONST.RED_BRICK_ROAD_PENDING_ACTION,
                         category: CONST.RED_BRICK_ROAD_PENDING_ACTION,
                         created: CONST.RED_BRICK_ROAD_PENDING_ACTION,

    Demo of the fix

    1.mp4

    What alternative solutions did you explore? (Optional)

    Keep user-selected tax code in memory when picked manually, then run a delayed post-create tax patch (with retries) after expense creation APIs, so the final transaction tax code is re-applied once optimistic creation settles.

    1. src/libs/actions/IOU/index.ts
      Added manual-tax tracking, added enqueueManualTaxPatch() retry helper, hooked it into REQUEST_MONEY / TRACK_EXPENSE / CREATE_DISTANCE_REQUEST, and extended setMoneyRequestTaxRate() with a manual-selection flag.
    index d37630cc1b5..65da2754c21 100644
    --- a/src/libs/actions/IOU/index.ts
    +++ b/src/libs/actions/IOU/index.ts
    @@ -38,7 +38,7 @@ import type {
         UpdateMoneyRequestParams,
     } from '@libs/API/parameters';
     import {WRITE_COMMANDS} from '@libs/API/types';
    -import {convertAmountToDisplayString, convertToDisplayString, convertToFrontendAmountAsString} from '@libs/CurrencyUtils';
    +import {convertAmountToDisplayString, convertToBackendAmount, convertToDisplayString, convertToFrontendAmountAsString, getCurrencyDecimals} from '@libs/CurrencyUtils';
     import DateUtils from '@libs/DateUtils';
     import DistanceRequestUtils from '@libs/DistanceRequestUtils';
     import {getMicroSecondOnyxErrorObject, getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
    @@ -201,12 +201,14 @@ import {startSpan} from '@libs/telemetry/activeSpans';
     import {
         allHavePendingRTERViolation,
         buildOptimisticTransaction,
    +    calculateTaxAmount,
         getAmount,
         getCategoryTaxCodeAndAmount,
         getClearedPendingFields,
         getCurrency,
         getDistanceInMeters,
         getMerchant,
    +    getTaxValue,
         getUpdatedTransaction,
         hasAnyTransactionWithoutRTERViolation,
         hasDuplicateTransactions,
    @@ -893,6 +895,26 @@ type PayMoneyRequestFunctionParams = {
         betas: OnyxEntry<OnyxTypes.Beta[]>;
     };
     
    +type ManualTaxPatchParams = {
    +    transactionID: string | undefined;
    +    transactionThreadReportID: string | undefined;
    +    iouReportID: string | undefined;
    +    desiredTaxCode: string;
    +    shouldPatch: boolean;
    +    policy: OnyxEntry<OnyxTypes.Policy>;
    +    policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>;
    +    policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>;
    +    currentUserAccountIDParam: number;
    +    currentUserEmailParam: string;
    +    isASAPSubmitBetaEnabled: boolean;
    +    parentReportNextStep: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
    +};
    +
    +const MANUAL_TAX_PATCH_DELAY_MS = 1200;
    +const MANUAL_TAX_PATCH_MAX_ATTEMPTS = 5;
    +
    +const manualTaxSelectionByTransactionID: Record<string, string> = {};
    +
     let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
     Onyx.connect({
         key: ONYXKEYS.COLLECTION.TRANSACTION,
    @@ -1165,6 +1187,55 @@ function handleNavigateAfterExpenseCreate({
         });
     }
     
    +function enqueueManualTaxPatch(params: ManualTaxPatchParams, attempt = 0) {
    +    const {transactionID, shouldPatch, desiredTaxCode} = params;
    +    if (!shouldPatch || !transactionID || !desiredTaxCode) {
    +        return;
    +    }
    +
    +    setTimeout(
    +        () => {
    +            const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
    +            const parentReport = params.iouReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${params.iouReportID}`] : undefined;
    +
    +            // Wait until optimistic creation settles and required report data is available.
    +            if (!transaction || !parentReport || transaction.pendingAction || transaction.isLoading) {
    +                if (attempt < MANUAL_TAX_PATCH_MAX_ATTEMPTS - 1) {
    +                    enqueueManualTaxPatch(params, attempt + 1);
    +                } else {
    +                    delete manualTaxSelectionByTransactionID[transactionID];
    +                }
    +                return;
    +            }
    +
    +            const transactionThreadReport = params.transactionThreadReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${params.transactionThreadReportID}`] : undefined;
    +            const transactionAmount = getAmount(transaction, false, true);
    +            const taxValue = getTaxValue(params.policy, transaction, desiredTaxCode) ?? '';
    +            const decimals = getCurrencyDecimals(getCurrency(transaction));
    +            const taxAmount = convertToBackendAmount(calculateTaxAmount(taxValue, transactionAmount, decimals));
    +
    +            updateMoneyRequestTaxRate({
    +                transactionID,
    +                transactionThreadReport,
    +                parentReport,
    +                taxCode: desiredTaxCode,
    +                taxAmount,
    +                taxValue,
    +                policy: params.policy,
    +                policyTagList: params.policyTagList,
    +                policyCategories: params.policyCategories,
    +                currentUserAccountIDParam: params.currentUserAccountIDParam,
    +                currentUserEmailParam: params.currentUserEmailParam,
    +                isASAPSubmitBetaEnabled: params.isASAPSubmitBetaEnabled,
    +                parentReportNextStep: params.parentReportNextStep,
    +            });
    +
    +            delete manualTaxSelectionByTransactionID[transactionID];
    +        },
    +        MANUAL_TAX_PATCH_DELAY_MS * (attempt + 1),
    +    );
    +}
    +
     /**
      * Build a minimal transaction record for formula computation in buildOptimisticExpenseReport.
      * This allows formulas like {report:startdate}, {report:expensescount} to work correctly.
    @@ -6554,6 +6625,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
             personalDetails,
         } = requestMoneyInformation;
         const {payeeAccountID} = participantParams;
    +    const {policy, policyCategories, policyTagList} = policyParams;
         const parsedComment = getParsedComment(transactionParams.comment ?? '');
         transactionParams.comment = parsedComment;
         const {
    @@ -6654,6 +6726,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
             betas,
             personalDetails,
         });
    +    const manualTaxCode = transaction?.transactionID ? manualTaxSelectionByTransactionID[transaction.transactionID] : undefined;
         const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID;
     
         if (shouldPlaySound) {
    @@ -6776,6 +6849,21 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep
                 };
                 // eslint-disable-next-line rulesdir/no-multiple-api-calls
                 API.write(WRITE_COMMANDS.REQUEST_MONEY, parameters, onyxData);
    +
    +            enqueueManualTaxPatch({
    +                transactionID: transaction.transactionID,
    +                transactionThreadReportID,
    +                iouReportID: iouReport.reportID,
    +                desiredTaxCode: manualTaxCode ?? '',
    +                shouldPatch: !!manualTaxCode,
    +                policy,
    +                policyTagList,
    +                policyCategories,
    +                currentUserAccountIDParam,
    +                currentUserEmailParam,
    +                isASAPSubmitBetaEnabled,
    +                parentReportNextStep: undefined,
    +            });
             }
         }
     
    @@ -7480,6 +7568,7 @@ function trackExpense(params: CreateTrackExpenseParams) {
             quickAction,
             betas,
         }) ?? {};
    +    const manualTaxCode = transaction?.transactionID ? manualTaxSelectionByTransactionID[transaction.transactionID] : undefined;
         const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport?.reportID;
         const onyxData: TrackedExpenseParams['onyxData'] = trackExpenseInformationOnyxData;
     
    @@ -7663,6 +7752,21 @@ function trackExpense(params: CreateTrackExpenseParams) {
                 }
     
                 API.write(WRITE_COMMANDS.TRACK_EXPENSE, parameters, onyxData);
    +
    +            enqueueManualTaxPatch({
    +                transactionID: transaction?.transactionID,
    +                transactionThreadReportID,
    +                iouReportID: iouReport?.reportID,
    +                desiredTaxCode: manualTaxCode ?? '',
    +                shouldPatch: !!manualTaxCode,
    +                policy,
    +                policyTagList,
    +                policyCategories,
    +                currentUserAccountIDParam,
    +                currentUserEmailParam,
    +                isASAPSubmitBetaEnabled,
    +                parentReportNextStep: undefined,
    +            });
             }
         }
     
    @@ -8316,6 +8420,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
             : receipt;
     
         let parameters: CreateDistanceRequestParams;
    +    let manualTaxPatchParams: ManualTaxPatchParams | undefined;
         let onyxData: OnyxData<BuildOnyxDataForMoneyRequestKeys | typeof ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE | typeof ONYXKEYS.NVP_RECENT_WAYPOINTS | typeof ONYXKEYS.GPS_DRAFT_DETAILS>;
         const sanitizedWaypoints = !isManualDistanceRequest ? sanitizeRecentWaypoints(validWaypoints) : null;
         if (iouType === CONST.IOU.TYPE.SPLIT) {
    @@ -8490,6 +8595,22 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
                 attendees: attendees ? JSON.stringify(attendees) : undefined,
                 gpsCoordinates,
             };
    +
    +        const manualTaxCode = transaction.transactionID ? manualTaxSelectionByTransactionID[transaction.transactionID] : undefined;
    +        manualTaxPatchParams = {
    +            transactionID: transaction.transactionID,
    +            transactionThreadReportID,
    +            iouReportID: iouReport.reportID,
    +            desiredTaxCode: manualTaxCode ?? '',
    +            shouldPatch: !!manualTaxCode,
    +            policy,
    +            policyTagList,
    +            policyCategories,
    +            currentUserAccountIDParam: currentUserAccountID,
    +            currentUserEmailParam: currentUserLogin,
    +            isASAPSubmitBetaEnabled,
    +            parentReportNextStep: undefined,
    +        };
         }
     
         const recentServerValidatedWaypoints = recentWaypoints.filter((item) => !item.pendingAction);
    @@ -8502,6 +8623,9 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
         playSound(SOUNDS.DONE);
     
         API.write(WRITE_COMMANDS.CREATE_DISTANCE_REQUEST, parameters, onyxData);
    +    if (manualTaxPatchParams) {
    +        enqueueManualTaxPatch(manualTaxPatchParams);
    +    }
         // eslint-disable-next-line @typescript-eslint/no-deprecated
         InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
         const activeReportID = isMoneyRequestReport && report?.reportID ? report.reportID : parameters.chatReportID;
    @@ -12335,7 +12459,12 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On
         });
     }
     
    -function setMoneyRequestTaxRate(transactionID: string, taxCode: string | null, isDraft = true) {
    +function setMoneyRequestTaxRate(transactionID: string, taxCode: string | null, isDraft = true, isTaxCodeManuallySelected = false) {
    +    if (isTaxCodeManuallySelected && taxCode) {
    +        manualTaxSelectionByTransactionID[transactionID] = taxCode;
    +    } else {
    +        delete manualTaxSelectionByTransactionID[transactionID];
    +    }
         Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {taxCode});
     }
    1. src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx
      When user selects tax, mark it as manual (isTaxCodeManuallySelected=true) so the post-create patch logic can re-apply it reliably.
    index d6a0b9b618e..026aa36e3b7 100644
    --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx
    +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx
    @@ -117,7 +117,7 @@ function IOURequestStepTaxRatePage({
                 return;
             }
             const amountInSmallestCurrencyUnits = convertToBackendAmount(taxAmount);
    -        setMoneyRequestTaxRate(currentTransaction?.transactionID, taxes?.code ?? '');
    +        setMoneyRequestTaxRate(currentTransaction?.transactionID, taxes?.code ?? '', true, true);
             setMoneyRequestTaxAmount(currentTransaction.transactionID, amountInSmallestCurrencyUnits);
     
             navigateBack();
  16. github-actions commented on Feb 23, 2026

    @github-actions
    Contributor

    ⚠️ @bilalup 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.

  17. JS00001 commented on Feb 23, 2026

    @JS00001
    Contributor

    We decided we should override this

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.EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsHourlyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions