From 105654d8696819583aaa8c7a21594f9aa8ced203 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Thu, 19 Mar 2026 13:27:59 +0530 Subject: [PATCH] Revert "Improve deleted tax behavior" --- .../ReportActionItem/MoneyRequestView.tsx | 10 +---- src/components/TaxPicker.tsx | 35 ++--------------- .../step/IOURequestStepTaxRatePage.tsx | 39 ++++++++----------- 3 files changed, 21 insertions(+), 63 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 0b322c4baa1a7..4c8291c90a7a7 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, @@ -306,12 +305,7 @@ function MoneyRequestView({ : convertToDisplayString(Math.abs(transactionTaxAmount ?? 0), actualCurrency); const taxRatesDescription = taxRates?.name; - - 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 = updatedTransaction ? getTaxName(policy, updatedTransaction, isExpenseUnreported) : getTaxName(policy, transaction, isExpenseUnreported); const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction) : transactionDate; const fallbackTaxRateTitle = transaction?.taxValue; @@ -598,7 +592,7 @@ function MoneyRequestView({ const decodedCategoryName = getDecodedCategoryName(categoryValue); const categoryCopyValue = !canEdit ? decodedCategoryName : undefined; const cardCopyValue = cardProgramName; - const taxRateValue = hasTaxValueChanged ? taxValue : (transaction?.taxName ?? taxRateTitle ?? fallbackTaxRateTitle ?? ''); + const taxRateValue = 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 98335720b5658..b7d0c2e12effb 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, shouldClearTax?: boolean) => void; + onSubmit: (tax: TaxRatesOption) => void; /** The action to take */ action?: IOUAction; @@ -68,22 +68,6 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act const shouldShowTextInput = !isTaxRatesCountBelowThreshold; - const {taxCode, taxValue} = transaction ?? {}; - const hasTaxBeenDeleted = !!taxCode && taxValue !== undefined && !taxRates?.taxes?.[taxCode]; - const hasTaxValueChanged = !!taxCode && taxValue !== undefined && taxRates?.taxes?.[taxCode]?.value !== taxValue; - - const deletedTaxOption = !hasTaxBeenDeleted - ? null - : { - code: undefined, - text: taxValue ?? '', - keyForList: taxCode ?? '', - searchText: taxValue ?? '', - tooltipText: taxValue ?? '', - isDisabled: true, - isSelected: true, - }; - const selectedOptions = selectedTaxRate ? [ { @@ -105,17 +89,11 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act const selectedOptionKey = sections?.at(0)?.data?.find((taxRate) => taxRate.searchText === selectedTaxRate)?.keyForList; const handleSelectRow = (newSelectedOption: TaxRatesOption) => { - if (hasTaxValueChanged) { - onSubmit(newSelectedOption, !newSelectedOption.code); - return; - } - if (selectedOptionKey === newSelectedOption.keyForList) { onDismiss(); return; } - - onSubmit(newSelectedOption, hasTaxBeenDeleted); + onSubmit(newSelectedOption); }; const textInputOptions = { @@ -125,16 +103,9 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act headerMessage: getHeaderMessageForNonUserList((sections.at(0)?.data?.length ?? 0) > 0, searchValue), }; - const updatedSections = deletedTaxOption - ? sections.map((section) => ({ - ...section, - data: [...section.data.map((item) => (item.code === deletedTaxOption.code ? {...item, isSelected: false} : item)), deletedTaxOption], - })) - : sections; - return ( { - 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; - } + const updateTaxRates = (taxes: TaxRatesOption) => { if (!currentTransaction || !taxes.code || !taxRates) { Navigation.goBack(); return; @@ -118,7 +97,21 @@ function IOURequestStepTaxRatePage({ if (isEditing) { const newTaxCode = taxes.code; - updateMoneyRequestTaxRate({...updateTaxRateParams, taxCode: newTaxCode, taxValue, taxAmount: convertToBackendAmount(taxAmount ?? 0)}); + updateMoneyRequestTaxRate({ + transactionID: currentTransaction?.transactionID, + transactionThreadReport: report, + parentReport, + taxCode: newTaxCode, + taxValue, + taxAmount: convertToBackendAmount(taxAmount ?? 0), + policy, + policyTagList: policyTags, + policyCategories, + currentUserAccountIDParam, + currentUserEmailParam, + isASAPSubmitBetaEnabled, + parentReportNextStep, + }); navigateBack(); return; }