Skip to content

Commit 927d463

Browse files
MelvinBot{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"}
andcommitted
Include track-expense tax contexts in the currency-change tax recompute guard
Co-authored-by: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"} <{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"}@users.noreply.github.com>
1 parent 1ee4be6 commit 927d463

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/libs/IOUAmountSubmission.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {getLoginByAccountID} from './PersonalDetailsUtils';
4848
import {isTaxTrackingEnabled} from './PolicyUtils';
4949
import {getPolicyExpenseChat, getTransactionDetails, isMoneyRequestReport, isPolicyExpenseChat, isSelfDM, shouldEnableNegative} from './ReportUtils';
5050
import shouldUseDefaultExpensePolicy from './shouldUseDefaultExpensePolicy';
51-
import {calculateTaxAmount, getAmount, getCurrency, getDefaultTaxCode, getIsFromGlobalCreate, getTaxValue, hasReceipt} from './TransactionUtils';
51+
import {calculateTaxAmount, getAmount, getCurrency, getDefaultTaxCode, getIsFromGlobalCreate, getTaxValue, hasReceipt, isExpenseUnreported} from './TransactionUtils';
5252

5353
type SubmitAmountArgs = {
5454
report: OnyxEntry<OnyxTypes.Report>;
@@ -516,7 +516,15 @@ function submitCreateAmount(args: SubmitAmountArgs, ctx: SubmitAmountContext): v
516516
const previousCurrency = getCurrency(transaction);
517517
const isCurrentTaxAutoDefault = isTaxCodeAutoDefaultForCurrency(policy, transaction, previousCurrency, transaction?.taxCode);
518518
const isPolicyExpenseChatParticipant = transaction?.participants?.some((participant) => participant.isPolicyExpenseChat) ?? false;
519-
const isTaxEnabled = isTaxTrackingEnabled(isPolicyExpenseChat(report) || isPolicyExpenseChatParticipant, policy, false);
519+
// Mirror the tax contexts the confirmation list uses (see MoneyRequestConfirmationList's shouldShowTax): a Track
520+
// expense from a self-DM/default workspace isn't a policy expense chat, but the confirmation page still shows tax
521+
// for the track flow, so the currency recompute must run for it too. Otherwise Back → change currency → Next would
522+
// leave the stale previous-currency default tax on the draft.
523+
const isTaxEnabled = isTaxTrackingEnabled(
524+
isPolicyExpenseChat(report) || isPolicyExpenseChatParticipant || iouType === CONST.IOU.TYPE.TRACK || isExpenseUnreported(transaction),
525+
policy,
526+
false,
527+
);
520528

521529
if (isMovingTransactionFromTrackExpense(action) || (isTaxEnabled && selectedCurrency !== previousCurrency && isCurrentTaxAutoDefault)) {
522530
const taxCode = getDefaultTaxCode(policy, transaction, selectedCurrency);

0 commit comments

Comments
 (0)