Skip to content

Commit 1bc48dd

Browse files
authored
Merge pull request #85738 from Expensify/revert-78472-73033-invalid-tax-after-edit
[CP Staging] Revert "Improve deleted tax behavior"
2 parents 2dfe23b + 105654d commit 1bc48dd

3 files changed

Lines changed: 21 additions & 63 deletions

File tree

src/components/ReportActionItem/MoneyRequestView.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ import {
9090
getTagArrayFromName,
9191
getTagForDisplay,
9292
getTaxName,
93-
getTaxValue,
9493
hasMissingSmartscanFields,
9594
hasMultipleSplitChildren,
9695
hasReservationList,
@@ -306,12 +305,7 @@ function MoneyRequestView({
306305
: convertToDisplayString(Math.abs(transactionTaxAmount ?? 0), actualCurrency);
307306

308307
const taxRatesDescription = taxRates?.name;
309-
310-
const baseTransaction = updatedTransaction ?? transaction;
311-
const {taxCode, taxValue} = baseTransaction ?? {};
312-
313-
const taxRateTitle = taxCode ? getTaxName(policy, baseTransaction, isExpenseUnreported) : '';
314-
const hasTaxValueChanged = taxCode ? getTaxValue(policy, baseTransaction, taxCode) !== baseTransaction?.taxValue : false;
308+
const taxRateTitle = updatedTransaction ? getTaxName(policy, updatedTransaction, isExpenseUnreported) : getTaxName(policy, transaction, isExpenseUnreported);
315309

316310
const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction) : transactionDate;
317311
const fallbackTaxRateTitle = transaction?.taxValue;
@@ -598,7 +592,7 @@ function MoneyRequestView({
598592
const decodedCategoryName = getDecodedCategoryName(categoryValue);
599593
const categoryCopyValue = !canEdit ? decodedCategoryName : undefined;
600594
const cardCopyValue = cardProgramName;
601-
const taxRateValue = hasTaxValueChanged ? taxValue : (transaction?.taxName ?? taxRateTitle ?? fallbackTaxRateTitle ?? '');
595+
const taxRateValue = transaction?.taxName ?? taxRateTitle ?? fallbackTaxRateTitle;
602596
const taxRateCopyValue = !canEditTaxFields ? taxRateValue : undefined;
603597
const taxAmountTitle = formattedTaxAmount ? formattedTaxAmount.toString() : '';
604598
const taxAmountCopyValue = !canEditTaxFields ? taxAmountTitle : undefined;

src/components/TaxPicker.tsx

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type TaxPickerProps = {
2626
transactionID?: string;
2727

2828
/** Callback to fire when a tax is pressed */
29-
onSubmit: (tax: TaxRatesOption, shouldClearTax?: boolean) => void;
29+
onSubmit: (tax: TaxRatesOption) => void;
3030

3131
/** The action to take */
3232
action?: IOUAction;
@@ -68,22 +68,6 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act
6868

6969
const shouldShowTextInput = !isTaxRatesCountBelowThreshold;
7070

71-
const {taxCode, taxValue} = transaction ?? {};
72-
const hasTaxBeenDeleted = !!taxCode && taxValue !== undefined && !taxRates?.taxes?.[taxCode];
73-
const hasTaxValueChanged = !!taxCode && taxValue !== undefined && taxRates?.taxes?.[taxCode]?.value !== taxValue;
74-
75-
const deletedTaxOption = !hasTaxBeenDeleted
76-
? null
77-
: {
78-
code: undefined,
79-
text: taxValue ?? '',
80-
keyForList: taxCode ?? '',
81-
searchText: taxValue ?? '',
82-
tooltipText: taxValue ?? '',
83-
isDisabled: true,
84-
isSelected: true,
85-
};
86-
8771
const selectedOptions = selectedTaxRate
8872
? [
8973
{
@@ -105,17 +89,11 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act
10589
const selectedOptionKey = sections?.at(0)?.data?.find((taxRate) => taxRate.searchText === selectedTaxRate)?.keyForList;
10690

10791
const handleSelectRow = (newSelectedOption: TaxRatesOption) => {
108-
if (hasTaxValueChanged) {
109-
onSubmit(newSelectedOption, !newSelectedOption.code);
110-
return;
111-
}
112-
11392
if (selectedOptionKey === newSelectedOption.keyForList) {
11493
onDismiss();
11594
return;
11695
}
117-
118-
onSubmit(newSelectedOption, hasTaxBeenDeleted);
96+
onSubmit(newSelectedOption);
11997
};
12098

12199
const textInputOptions = {
@@ -125,16 +103,9 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act
125103
headerMessage: getHeaderMessageForNonUserList((sections.at(0)?.data?.length ?? 0) > 0, searchValue),
126104
};
127105

128-
const updatedSections = deletedTaxOption
129-
? sections.map((section) => ({
130-
...section,
131-
data: [...section.data.map((item) => (item.code === deletedTaxOption.code ? {...item, isSelected: false} : item)), deletedTaxOption],
132-
}))
133-
: sections;
134-
135106
return (
136107
<SelectionListWithSections
137-
sections={updatedSections}
108+
sections={sections}
138109
shouldShowTextInput={shouldShowTextInput}
139110
textInputOptions={textInputOptions}
140111
onSelectRow={handleSelectRow}

src/pages/iou/request/step/IOURequestStepTaxRatePage.tsx

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,7 @@ function IOURequestStepTaxRatePage({
7676
const currency = getCurrency(currentTransaction);
7777
const decimals = getCurrencyDecimals(currency);
7878

79-
const updateTaxRates = (taxes: TaxRatesOption, shouldClearTax?: boolean) => {
80-
const updateTaxRateParams = {
81-
transactionID: currentTransaction?.transactionID,
82-
transactionThreadReport: report,
83-
parentReport,
84-
taxCode: '',
85-
taxValue: '',
86-
taxAmount: 0,
87-
policy,
88-
policyTagList: policyTags,
89-
policyCategories,
90-
currentUserAccountIDParam,
91-
currentUserEmailParam,
92-
isASAPSubmitBetaEnabled,
93-
parentReportNextStep,
94-
};
95-
96-
if (shouldClearTax && isEditing) {
97-
updateMoneyRequestTaxRate(updateTaxRateParams);
98-
navigateBack();
99-
return;
100-
}
79+
const updateTaxRates = (taxes: TaxRatesOption) => {
10180
if (!currentTransaction || !taxes.code || !taxRates) {
10281
Navigation.goBack();
10382
return;
@@ -118,7 +97,21 @@ function IOURequestStepTaxRatePage({
11897

11998
if (isEditing) {
12099
const newTaxCode = taxes.code;
121-
updateMoneyRequestTaxRate({...updateTaxRateParams, taxCode: newTaxCode, taxValue, taxAmount: convertToBackendAmount(taxAmount ?? 0)});
100+
updateMoneyRequestTaxRate({
101+
transactionID: currentTransaction?.transactionID,
102+
transactionThreadReport: report,
103+
parentReport,
104+
taxCode: newTaxCode,
105+
taxValue,
106+
taxAmount: convertToBackendAmount(taxAmount ?? 0),
107+
policy,
108+
policyTagList: policyTags,
109+
policyCategories,
110+
currentUserAccountIDParam,
111+
currentUserEmailParam,
112+
isASAPSubmitBetaEnabled,
113+
parentReportNextStep,
114+
});
122115
navigateBack();
123116
return;
124117
}

0 commit comments

Comments
 (0)