From 996e18e9ce5993eebf65ad02551d6fcde87a8b07 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 23 Jun 2026 16:19:21 +0700 Subject: [PATCH 1/2] update previousTaxCode in setPolicyTaxCode successData --- src/libs/actions/TaxRate.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/TaxRate.ts b/src/libs/actions/TaxRate.ts index 3a6373108e95..8d324a9f884d 100644 --- a/src/libs/actions/TaxRate.ts +++ b/src/libs/actions/TaxRate.ts @@ -608,6 +608,7 @@ function setPolicyTaxCode( pendingFields: {...originalTaxRate.pendingFields, code: null}, pendingAction: null, errorFields: {code: null}, + previousTaxCode: oldTaxCode, }, }, }, From 3b4b3ca00815840de5e9f3b7d39dc657933f7aff Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Sun, 28 Jun 2026 18:24:43 +0700 Subject: [PATCH 2/2] use optimisticPreviousTaxCode in getCurrentTaxID --- src/libs/PolicyUtils.ts | 2 +- src/libs/actions/TaxRate.ts | 2 ++ src/types/onyx/Policy.ts | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 2e6789fc98fa..3159b732e705 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -2286,7 +2286,7 @@ function hasOnlyPersonalPolicies(policies: OnyxCollection) { } function getCurrentTaxID(policy: OnyxEntry, taxID: string): string | undefined { - return Object.keys(policy?.taxRates?.taxes ?? {}).find((taxIDKey) => policy?.taxRates?.taxes?.[taxIDKey].previousTaxCode === taxID || taxIDKey === taxID); + return Object.keys(policy?.taxRates?.taxes ?? {}).find((taxIDKey) => policy?.taxRates?.taxes?.[taxIDKey].optimisticPreviousTaxCode === taxID || taxIDKey === taxID); } function getTagApproverRule(policy: OnyxEntry, tagName: string) { diff --git a/src/libs/actions/TaxRate.ts b/src/libs/actions/TaxRate.ts index 8d324a9f884d..469842f32cb8 100644 --- a/src/libs/actions/TaxRate.ts +++ b/src/libs/actions/TaxRate.ts @@ -585,6 +585,7 @@ function setPolicyTaxCode( pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, errorFields: {code: null}, previousTaxCode: oldTaxCode, + optimisticPreviousTaxCode: oldTaxCode, }, }, }, @@ -609,6 +610,7 @@ function setPolicyTaxCode( pendingAction: null, errorFields: {code: null}, previousTaxCode: oldTaxCode, + optimisticPreviousTaxCode: null, }, }, }, diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 7473b11e5d4c..ed897a84d00f 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -244,6 +244,9 @@ type TaxRate = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The old tax code of the tax rate when we edit the tax code */ previousTaxCode?: string; + /** The old tax code kept only while a tax code edit is in flight, used to resolve the rate from the old code; cleared once the API resolves */ + optimisticPreviousTaxCode?: string; + /** An error message to display to the user */ errors?: OnyxCommon.Errors;