@@ -253,8 +253,6 @@ function MoneyRequestConfirmationList({
253253 selector : mileageRateSelector ,
254254 canBeMissing : true ,
255255 } ) ;
256- const { policyForMovingExpenses} = usePolicyForMovingExpenses ( ) ;
257- const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseUtil ( action ) ;
258256 const [ defaultMileageRateReal ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` , {
259257 selector : mileageRateSelector ,
260258 canBeMissing : true ,
@@ -282,6 +280,7 @@ function MoneyRequestConfirmationList({
282280 isTestDriveReceipt || isManagerMcTestReceipt ,
283281 ) ;
284282
283+ const { policyForMovingExpenses} = usePolicyForMovingExpenses ( ) ;
285284 const isTrackExpense = iouType === CONST . IOU . TYPE . TRACK ;
286285 const policy = isTrackExpense ? policyForMovingExpenses : ( policyReal ?? policyDraft ) ;
287286 const policyCategories = policyCategoriesReal ?? policyCategoriesDraft ;
@@ -299,6 +298,7 @@ function MoneyRequestConfirmationList({
299298 const isTypeInvoice = iouType === CONST . IOU . TYPE . INVOICE ;
300299 const isScanRequest = useMemo ( ( ) => isScanRequestUtil ( transaction ) , [ transaction ] ) ;
301300 const isCreateExpenseFlow = ! ! transaction ?. isFromGlobalCreate && ! isPerDiemRequest ;
301+ const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseUtil ( action ) ;
302302
303303 const transactionID = transaction ?. transactionID ;
304304 const customUnitRateID = getRateID ( transaction ) ;
@@ -342,18 +342,16 @@ function MoneyRequestConfirmationList({
342342
343343 const policyTagLists = useMemo ( ( ) => getTagLists ( policyTags ) , [ policyTags ] ) ;
344344
345- const shouldShowTax = isTaxTrackingEnabled ( isPolicyExpenseChat || isTrackExpense , policy , isDistanceRequest , isPerDiemRequest ) ;
345+ const shouldShowTax = isTaxTrackingEnabled ( isPolicyExpenseChat , policy , isDistanceRequest , isPerDiemRequest ) ;
346346
347347 // Update the tax code when the default changes (for example, because the transaction currency changed)
348- const defaultTaxCode = getDefaultTaxCode ( policy , transaction ) ?? ( isMovingTransactionFromTrackExpense ? ( getDefaultTaxCode ( policyForMovingExpenses , transaction ) ?? '' ) : '' ) ;
349-
348+ const defaultTaxCode = getDefaultTaxCode ( policy , transaction ) ?? '' ;
350349 useEffect ( ( ) => {
351- if ( ! transactionID || isReadOnly || ! shouldShowTax || isMovingTransactionFromTrackExpense ) {
350+ if ( ! transactionID || isReadOnly || ! shouldShowTax ) {
352351 return ;
353352 }
354353 setMoneyRequestTaxRate ( transactionID , defaultTaxCode ) ;
355- // trigger this useEffect also when policyID changes - the defaultTaxCode may stay the same
356- } , [ defaultTaxCode , isMovingTransactionFromTrackExpense , isReadOnly , transactionID , policyID , shouldShowTax ] ) ;
354+ } , [ defaultTaxCode , transactionID , isReadOnly , shouldShowTax ] ) ;
357355
358356 const distance = getDistanceInMeters ( transaction , unit ) ;
359357 const prevDistance = usePrevious ( distance ) ;
@@ -504,18 +502,15 @@ function MoneyRequestConfirmationList({
504502
505503 // Calculate and set tax amount in transaction draft
506504 const taxableAmount = isDistanceRequest ? DistanceRequestUtils . getTaxableAmount ( policy , customUnitRateID , distance ) : ( transaction ?. amount ?? 0 ) ;
507- // First we'll try to get the tax value from the chosen policy and if not found, we'll try to get it from the policy for moving expenses (only if the transaction is moving from track expense)
508- const taxPercentage =
509- getTaxValue ( policy , transaction , transaction ?. taxCode ?? defaultTaxCode ) ??
510- ( isMovingTransactionFromTrackExpense ? getTaxValue ( policyForMovingExpenses , transaction , transaction ?. taxCode ?? defaultTaxCode ) : '' ) ;
505+ const taxPercentage = getTaxValue ( policy , transaction , transaction ?. taxCode ?? defaultTaxCode ) ?? '' ;
511506 const taxAmount = calculateTaxAmount ( taxPercentage , taxableAmount , transaction ?. currency ?? CONST . CURRENCY . USD ) ;
512507 const taxAmountInSmallestCurrencyUnits = convertToBackendAmount ( Number . parseFloat ( taxAmount . toString ( ) ) ) ;
513508 useEffect ( ( ) => {
514- if ( ! transactionID || isMovingTransactionFromTrackExpense || isReadOnly || ! shouldShowTax ) {
509+ if ( ! transactionID || isReadOnly || ! shouldShowTax ) {
515510 return ;
516511 }
517512 setMoneyRequestTaxAmount ( transactionID , taxAmountInSmallestCurrencyUnits ) ;
518- } , [ transactionID , taxAmountInSmallestCurrencyUnits , isMovingTransactionFromTrackExpense , isReadOnly , shouldShowTax ] ) ;
513+ } , [ transactionID , taxAmountInSmallestCurrencyUnits , isReadOnly , shouldShowTax ] ) ;
519514
520515 // If completing a split expense fails, set didConfirm to false to allow the user to edit the fields again
521516 if ( isEditingSplitBill && didConfirm ) {
@@ -840,7 +835,7 @@ function MoneyRequestConfirmationList({
840835 if ( ! transactionID || iouCategory || ! shouldShowCategories || enabledCategories . length !== 1 || ! isCategoryRequired ) {
841836 return ;
842837 }
843- setMoneyRequestCategory ( transactionID , enabledCategories . at ( 0 ) ?. name ?? '' , policy , isMovingTransactionFromTrackExpense ) ;
838+ setMoneyRequestCategory ( transactionID , enabledCategories . at ( 0 ) ?. name ?? '' , policy ) ;
844839 // Keep 'transaction' out to ensure that we auto select the option only once
845840 // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
846841 } , [ shouldShowCategories , policyCategories , isCategoryRequired , policy ?. id ] ) ;
@@ -924,11 +919,6 @@ function MoneyRequestConfirmationList({
924919 return ;
925920 }
926921
927- if ( shouldShowTax && ! Object . keys ( policy ?. taxRates ?. taxes ?? { } ) . some ( ( key ) => key === transaction . taxCode ) ) {
928- setFormError ( 'violations.taxOutOfPolicy' ) ;
929- return ;
930- }
931-
932922 if ( isPerDiemRequest && ( transaction . comment ?. customUnit ?. subRates ?? [ ] ) . length === 0 ) {
933923 setFormError ( 'iou.error.invalidSubrateLength' ) ;
934924 return ;
@@ -986,7 +976,6 @@ function MoneyRequestConfirmationList({
986976 isMerchantRequired ,
987977 isMerchantEmpty ,
988978 shouldDisplayFieldError ,
989- shouldShowTax ,
990979 transaction ,
991980 policyTags ,
992981 isPerDiemRequest ,
0 commit comments