From 6790bc216ca83ca70b72bb0af63d62945d94a984 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Wed, 18 Mar 2026 21:14:23 +0700 Subject: [PATCH 1/6] fix duplicate --- src/components/TaxPicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index 98335720b565..9c8c8438ad83 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -128,7 +128,7 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act const updatedSections = deletedTaxOption ? sections.map((section) => ({ ...section, - data: [...section.data.map((item) => (item.code === deletedTaxOption.code ? {...item, isSelected: false} : item)), deletedTaxOption], + data: [...section.data.filter((item) => item.code !== deletedTaxOption.code), deletedTaxOption], })) : sections; From dfe74671097c4d507b09bee3b0c5bc293429dc45 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Thu, 19 Mar 2026 10:29:25 +0700 Subject: [PATCH 2/6] update condition get tax title --- src/components/ReportActionItem/MoneyRequestView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 0b322c4baa1a..9d9851f1ea3f 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -310,8 +310,8 @@ function MoneyRequestView({ const baseTransaction = updatedTransaction ?? transaction; const {taxCode, taxValue} = baseTransaction ?? {}; - const taxRateTitle = taxCode ? getTaxName(policy, baseTransaction, isExpenseUnreported) : ''; - const hasTaxValueChanged = taxCode ? getTaxValue(policy, baseTransaction, taxCode) !== baseTransaction?.taxValue : false; + const taxRateTitle = getTaxName(policy, baseTransaction, isExpenseUnreported); + const hasTaxValueChanged = taxCode && taxValue !== undefined ? getTaxValue(policy, baseTransaction, taxCode) !== taxValue : false; const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction) : transactionDate; const fallbackTaxRateTitle = transaction?.taxValue; From e99e8eae3f152210931d9f3e1a40095a5404e968 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Thu, 19 Mar 2026 10:53:25 +0700 Subject: [PATCH 3/6] update tax selected --- .../MoneyRequestConfirmationList.tsx | 17 ++++++++++++--- src/components/TaxPicker.tsx | 21 +++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index feb75bfef566..c14e22a77c7f 100644 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -24,7 +24,7 @@ import { setMoneyRequestPendingFields, setMoneyRequestTag, setMoneyRequestTaxAmount, - setMoneyRequestTaxRate, + setMoneyRequestTaxRateValues, } from '@libs/actions/IOU'; import {computePerDiemExpenseAmount, isValidPerDiemExpenseAmount} from '@libs/actions/IOU/PerDiem'; import {adjustRemainingSplitShares, resetSplitShares, setIndividualShare, setSplitShares} from '@libs/actions/IOU/Split'; @@ -380,14 +380,25 @@ function MoneyRequestConfirmationList({ // Update the tax code when the default changes (for example, because the transaction currency changed) const defaultTaxCode = getDefaultTaxCode(policy, transaction) ?? (isMovingTransactionFromTrackExpense ? (getDefaultTaxCode(policyForMovingExpenses, transaction) ?? '') : ''); + const defaultTaxValue = getTaxValue(policy, transaction, defaultTaxCode) ?? null; useEffect(() => { if (!transactionID || isReadOnly || !shouldShowTax || isMovingTransactionFromTrackExpense) { return; } - setMoneyRequestTaxRate(transactionID, defaultTaxCode); + + // Keep the user's current selection when it's still valid for the active policy. + if (hasTaxRateWithMatchingValue(policy, transaction)) { + return; + } + + setMoneyRequestTaxRateValues(transactionID, { + taxCode: defaultTaxCode, + taxValue: defaultTaxValue, + taxAmount: transaction?.taxAmount ?? null, + }); // trigger this useEffect also when policyID changes - the defaultTaxCode may stay the same - }, [defaultTaxCode, isMovingTransactionFromTrackExpense, isReadOnly, transactionID, policyID, shouldShowTax]); + }, [defaultTaxCode, defaultTaxValue, isMovingTransactionFromTrackExpense, isReadOnly, transactionID, policyID, shouldShowTax, policy, transaction]); const distance = getDistanceInMeters(transaction, unit); const prevDistance = usePrevious(distance); diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index 9c8c8438ad83..8e7b6e800f17 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -7,7 +7,7 @@ import Navigation from '@libs/Navigation/Navigation'; import {getHeaderMessageForNonUserList} from '@libs/OptionsListUtils'; import {getTaxRatesSection} from '@libs/TaxOptionsListUtils'; import type {TaxRatesOption} from '@libs/TaxOptionsListUtils'; -import {getEnabledTaxRateCount} from '@libs/TransactionUtils'; +import {getDefaultTaxCode, getEnabledTaxRateCount, transformedTaxRates} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import type {IOUAction} from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -68,7 +68,10 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act const shouldShowTextInput = !isTaxRatesCountBelowThreshold; - const {taxCode, taxValue} = transaction ?? {}; + const {taxCode, taxValue} = currentTransaction ?? {}; + const defaultTaxCode = getDefaultTaxCode(policy, currentTransaction) ?? ''; + const effectiveTaxCode = taxCode && taxCode.length > 0 ? taxCode : defaultTaxCode; + const effectiveSelectedTaxRate = selectedTaxRate || (effectiveTaxCode ? (transformedTaxRates(policy, currentTransaction)[effectiveTaxCode]?.modifiedName ?? '') : ''); const hasTaxBeenDeleted = !!taxCode && taxValue !== undefined && !taxRates?.taxes?.[taxCode]; const hasTaxValueChanged = !!taxCode && taxValue !== undefined && taxRates?.taxes?.[taxCode]?.value !== taxValue; @@ -84,10 +87,10 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act isSelected: true, }; - const selectedOptions = selectedTaxRate + const selectedOptions = effectiveSelectedTaxRate ? [ { - modifiedName: selectedTaxRate, + modifiedName: effectiveSelectedTaxRate, isDisabled: false, accountID: null, }, @@ -102,7 +105,9 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act transaction: currentTransaction, }); - const selectedOptionKey = sections?.at(0)?.data?.find((taxRate) => taxRate.searchText === selectedTaxRate)?.keyForList; + const flattenedOptions = sections.flatMap((section) => section.data); + const selectedOptionKey = + flattenedOptions.find((taxRate) => taxRate.code === effectiveTaxCode)?.keyForList ?? flattenedOptions.find((taxRate) => taxRate.searchText === effectiveSelectedTaxRate)?.keyForList; const handleSelectRow = (newSelectedOption: TaxRatesOption) => { if (hasTaxValueChanged) { @@ -110,7 +115,11 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act return; } - if (selectedOptionKey === newSelectedOption.keyForList) { + const isSameTaxCode = taxCode === newSelectedOption.code; + const currentTaxRateValue = taxCode ? taxRates?.taxes?.[taxCode]?.value : undefined; + const hasMatchingTaxValue = taxValue === undefined || currentTaxRateValue === taxValue; + + if (isSameTaxCode && hasMatchingTaxValue) { onDismiss(); return; } From f64f759b3973f8a6df22dbb021f1c0c66fdbf048 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Thu, 19 Mar 2026 13:47:49 +0700 Subject: [PATCH 4/6] update test --- src/components/MoneyRequestConfirmationList.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index c14e22a77c7f..1db26c35001d 100644 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -350,6 +350,7 @@ function MoneyRequestConfirmationList({ const isFromGlobalCreateAndCanEditParticipant = !!transaction?.isFromGlobalCreate && !isPerDiemRequest && !isTimeRequest; const transactionID = transaction?.transactionID; + const previousTransactionCurrency = usePrevious(transaction?.currency); const customUnitRateID = getRateID(transaction); const subRates = transaction?.comment?.customUnit?.subRates ?? []; @@ -381,6 +382,8 @@ function MoneyRequestConfirmationList({ // Update the tax code when the default changes (for example, because the transaction currency changed) const defaultTaxCode = getDefaultTaxCode(policy, transaction) ?? (isMovingTransactionFromTrackExpense ? (getDefaultTaxCode(policyForMovingExpenses, transaction) ?? '') : ''); const defaultTaxValue = getTaxValue(policy, transaction, defaultTaxCode) ?? null; + const previousDefaultTaxCode = getDefaultTaxCode(policy, transaction, previousTransactionCurrency); + const shouldKeepCurrentTaxSelection = hasTaxRateWithMatchingValue(policy, transaction) && transaction?.taxCode !== previousDefaultTaxCode; useEffect(() => { if (!transactionID || isReadOnly || !shouldShowTax || isMovingTransactionFromTrackExpense) { @@ -388,7 +391,7 @@ function MoneyRequestConfirmationList({ } // Keep the user's current selection when it's still valid for the active policy. - if (hasTaxRateWithMatchingValue(policy, transaction)) { + if (shouldKeepCurrentTaxSelection) { return; } @@ -398,7 +401,7 @@ function MoneyRequestConfirmationList({ taxAmount: transaction?.taxAmount ?? null, }); // trigger this useEffect also when policyID changes - the defaultTaxCode may stay the same - }, [defaultTaxCode, defaultTaxValue, isMovingTransactionFromTrackExpense, isReadOnly, transactionID, policyID, shouldShowTax, policy, transaction]); + }, [defaultTaxCode, defaultTaxValue, isMovingTransactionFromTrackExpense, isReadOnly, transactionID, policyID, shouldShowTax, shouldKeepCurrentTaxSelection, transaction?.taxAmount]); const distance = getDistanceInMeters(transaction, unit); const prevDistance = usePrevious(distance); From cb77155f7ccaee8db725c65ee6a157a33758a433 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Wed, 18 Mar 2026 11:07:23 +0530 Subject: [PATCH 5/6] update delete tax --- .../ReportActionItem/MoneyRequestView.tsx | 3 +- src/components/TaxPicker.tsx | 7 ++-- .../step/IOURequestStepTaxRatePage.tsx | 39 +++++++++++-------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index fee9c03ee016..9d9851f1ea3f 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -90,6 +90,7 @@ import { getTagArrayFromName, getTagForDisplay, getTaxName, + getTaxValue, hasMissingSmartscanFields, hasMultipleSplitChildren, hasReservationList, @@ -597,7 +598,7 @@ function MoneyRequestView({ const decodedCategoryName = getDecodedCategoryName(categoryValue); const categoryCopyValue = !canEdit ? decodedCategoryName : undefined; const cardCopyValue = cardProgramName; - const taxRateValue = transaction?.taxName ?? taxRateTitle ?? fallbackTaxRateTitle; + const taxRateValue = hasTaxValueChanged ? taxValue : (transaction?.taxName ?? taxRateTitle ?? fallbackTaxRateTitle ?? ''); const taxRateCopyValue = !canEditTaxFields ? taxRateValue : undefined; const taxAmountTitle = formattedTaxAmount ? formattedTaxAmount.toString() : ''; const taxAmountCopyValue = !canEditTaxFields ? taxAmountTitle : undefined; diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index 34e46e6f7f71..8e7b6e800f17 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -26,7 +26,7 @@ type TaxPickerProps = { transactionID?: string; /** Callback to fire when a tax is pressed */ - onSubmit: (tax: TaxRatesOption) => void; + onSubmit: (tax: TaxRatesOption, shouldClearTax?: boolean) => void; /** The action to take */ action?: IOUAction; @@ -123,7 +123,8 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act onDismiss(); return; } - onSubmit(newSelectedOption); + + onSubmit(newSelectedOption, hasTaxBeenDeleted); }; const textInputOptions = { @@ -142,7 +143,7 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act return ( { + const updateTaxRates = (taxes: TaxRatesOption, shouldClearTax?: boolean) => { + const updateTaxRateParams = { + transactionID: currentTransaction?.transactionID, + transactionThreadReport: report, + parentReport, + taxCode: '', + taxValue: '', + taxAmount: 0, + policy, + policyTagList: policyTags, + policyCategories, + currentUserAccountIDParam, + currentUserEmailParam, + isASAPSubmitBetaEnabled, + parentReportNextStep, + }; + + if (shouldClearTax && isEditing) { + updateMoneyRequestTaxRate(updateTaxRateParams); + navigateBack(); + return; + } if (!currentTransaction || !taxes.code || !taxRates) { Navigation.goBack(); return; @@ -97,21 +118,7 @@ function IOURequestStepTaxRatePage({ if (isEditing) { const newTaxCode = taxes.code; - updateMoneyRequestTaxRate({ - transactionID: currentTransaction?.transactionID, - transactionThreadReport: report, - parentReport, - taxCode: newTaxCode, - taxValue, - taxAmount: convertToBackendAmount(taxAmount ?? 0), - policy, - policyTagList: policyTags, - policyCategories, - currentUserAccountIDParam, - currentUserEmailParam, - isASAPSubmitBetaEnabled, - parentReportNextStep, - }); + updateMoneyRequestTaxRate({...updateTaxRateParams, taxCode: newTaxCode, taxValue, taxAmount: convertToBackendAmount(taxAmount ?? 0)}); navigateBack(); return; } From f184f8451084811a69fc536dec1e70ccc8f84fb0 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Fri, 20 Mar 2026 11:21:20 +0700 Subject: [PATCH 6/6] update way to get tax value --- src/components/ReportActionItem/MoneyRequestView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 9d9851f1ea3f..0dc346cdad7d 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -90,7 +90,6 @@ import { getTagArrayFromName, getTagForDisplay, getTaxName, - getTaxValue, hasMissingSmartscanFields, hasMultipleSplitChildren, hasReservationList, @@ -311,7 +310,8 @@ function MoneyRequestView({ const {taxCode, taxValue} = baseTransaction ?? {}; const taxRateTitle = getTaxName(policy, baseTransaction, isExpenseUnreported); - const hasTaxValueChanged = taxCode && taxValue !== undefined ? getTaxValue(policy, baseTransaction, taxCode) !== taxValue : false; + const selectedPolicyTaxValue = taxCode ? policy?.taxRates?.taxes?.[taxCode]?.value : undefined; + const hasTaxValueChanged = taxCode && taxValue !== undefined ? selectedPolicyTaxValue !== taxValue : false; const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction) : transactionDate; const fallbackTaxRateTitle = transaction?.taxValue;