diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index e08ff1d96d49..860accb5489b 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -47,7 +47,7 @@ function TaxPicker({selectedTaxRate = '', policy, insets, onSubmit}: TaxPickerPr const shouldShowTextInput = !isTaxRatesCountBelowThreshold; - const getTaxName = useCallback((key: string) => taxRates?.taxes[key].name, [taxRates?.taxes]); + const getTaxName = useCallback((key: string) => taxRates?.taxes[key]?.name, [taxRates?.taxes]); const selectedOptions = useMemo(() => { if (!selectedTaxRate) { diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index ef3d6dbe2808..2d3cdd03b8c2 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -162,12 +162,10 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p Navigation.dismissModal(); return; } - // optimisticall set tax amount. - IOU.setMoneyRequestTaxAmount(transaction.transactionID, getTaxAmount(-newAmount, transactionTaxCode, taxRates)); IOU.updateMoneyRequestAmountAndCurrency(transaction.transactionID, report.reportID, newCurrency, newAmount, policy, policyTags, policyCategories); Navigation.dismissModal(); }, - [transaction, report, policy, policyTags, policyCategories, taxRates, transactionTaxCode], + [transaction, report, policy, policyTags, policyCategories], ); const saveTag = useCallback( diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index b2e3841dfb16..a20fc99e8240 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -62,7 +62,7 @@ const getNewSelection = (oldSelection: Selection, prevLength: number, newLength: const isAmountInvalid = (amount: string) => !amount.length || parseFloat(amount) < 0.01; const isTaxAmountInvalid = (currentAmount: string, taxAmount: number, isTaxAmountForm: boolean) => - isTaxAmountForm && Number.parseFloat(currentAmount) > CurrencyUtils.convertToFrontendAmount(taxAmount); + isTaxAmountForm && Number.parseFloat(currentAmount) > CurrencyUtils.convertToFrontendAmount(Math.abs(taxAmount)); const AMOUNT_VIEW_ID = 'amountView'; const NUM_PAD_CONTAINER_VIEW_ID = 'numPadContainerView'; @@ -102,7 +102,7 @@ function MoneyRequestAmountForm( const forwardDeletePressedRef = useRef(false); - const formattedTaxAmount = CurrencyUtils.convertToDisplayString(taxAmount, currency); + const formattedTaxAmount = CurrencyUtils.convertToDisplayString(Math.abs(taxAmount), currency); /** * Event occurs when a user presses a mouse button over an DOM element.