Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0370977
fix: revert revert tsxes field
koko57 Dec 23, 2025
358c956
fix: recalculate the taxAmount when currency changes
koko57 Dec 23, 2025
be5ec78
fix: resolve conflicts
koko57 Jan 7, 2026
4c331ea
fix: remove the fix for the currency
koko57 Jan 7, 2026
b2fe60e
fix: resolve conflicts
koko57 Jan 7, 2026
e05ff24
fix: recalculate tax amount
koko57 Jan 7, 2026
a949f54
fix: resolve conflicts
koko57 Jan 7, 2026
b565775
fix: resolve conflicts
koko57 Jan 8, 2026
9eb8d7b
Merge branch 'main' into feat/72238-taxes-field-v3
koko57 Jan 12, 2026
398f0a1
fix: change and recalculate tax rate on currency change
koko57 Jan 12, 2026
11ad644
fix: resolve conflicts
koko57 Jan 13, 2026
9d3be2b
fix: resolve conflicts
koko57 Jan 16, 2026
875ea8c
Merge branch 'main' into feat/72238-taxes-field-v3
koko57 Jan 19, 2026
7f4396a
Merge branch 'main' into feat/72238-taxes-field-v3
koko57 Jan 19, 2026
ab592f0
fix: add policyID to track expense params
koko57 Jan 19, 2026
297f468
fix: prettier
koko57 Jan 19, 2026
3c66205
fix: fallback to tax value when names not match
koko57 Jan 19, 2026
6c9280c
fix: resolve conflicts
koko57 Jan 20, 2026
384f30d
fix: resolve conflicts
koko57 Jan 20, 2026
1c4c39b
fix: update taxValue according to new taxRate
koko57 Jan 20, 2026
1f6fac4
fix: show tax rate name when created offline
koko57 Jan 20, 2026
8575e03
fix: tests
koko57 Jan 21, 2026
0778490
fix: only check if tax rate matches when taxCode on the transaction o…
koko57 Jan 21, 2026
9ac724f
fix: resolve conflicts
koko57 Jan 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ function MoneyRequestConfirmationList({
selector: mileageRateSelector,
canBeMissing: true,
});
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseUtil(action);
const [defaultMileageRateReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
selector: mileageRateSelector,
canBeMissing: true,
Expand Down Expand Up @@ -301,7 +303,6 @@ function MoneyRequestConfirmationList({
isTestDriveReceipt || isManagerMcTestReceipt,
);

const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const isTrackExpense = iouType === CONST.IOU.TYPE.TRACK;
const policy = isTrackExpense ? policyForMovingExpenses : (policyReal ?? policyDraft);
const policyCategories = policyCategoriesReal ?? policyCategoriesDraft;
Expand All @@ -319,7 +320,6 @@ function MoneyRequestConfirmationList({
const isTypeInvoice = iouType === CONST.IOU.TYPE.INVOICE;
const isScanRequest = useMemo(() => isScanRequestUtil(transaction), [transaction]);
const isCreateExpenseFlow = !!transaction?.isFromGlobalCreate && !isPerDiemRequest;
const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseUtil(action);

const transactionID = transaction?.transactionID;
const customUnitRateID = getRateID(transaction);
Expand Down Expand Up @@ -363,16 +363,18 @@ function MoneyRequestConfirmationList({

const policyTagLists = useMemo(() => getTagLists(policyTags), [policyTags]);

const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest, isPerDiemRequest, isTimeRequest);
const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat || isTrackExpense, policy, isDistanceRequest, isPerDiemRequest, isTimeRequest);

// Update the tax code when the default changes (for example, because the transaction currency changed)
const defaultTaxCode = getDefaultTaxCode(policy, transaction) ?? '';
const defaultTaxCode = getDefaultTaxCode(policy, transaction) ?? (isMovingTransactionFromTrackExpense ? (getDefaultTaxCode(policyForMovingExpenses, transaction) ?? '') : '');

useEffect(() => {
if (!transactionID || isReadOnly || !shouldShowTax) {
if (!transactionID || isReadOnly || !shouldShowTax || isMovingTransactionFromTrackExpense) {
return;
}
setMoneyRequestTaxRate(transactionID, defaultTaxCode);
}, [defaultTaxCode, transactionID, isReadOnly, shouldShowTax]);
// trigger this useEffect also when policyID changes - the defaultTaxCode may stay the same
}, [defaultTaxCode, isMovingTransactionFromTrackExpense, isReadOnly, transactionID, policyID, shouldShowTax]);

const distance = getDistanceInMeters(transaction, unit);
const prevDistance = usePrevious(distance);
Expand Down Expand Up @@ -532,7 +534,10 @@ function MoneyRequestConfirmationList({

// Calculate and set tax amount in transaction draft
const taxableAmount = isDistanceRequest ? DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, distance) : (transaction?.amount ?? 0);
const taxPercentage = getTaxValue(policy, transaction, transaction?.taxCode ?? defaultTaxCode) ?? '';
// 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)
const taxPercentage =
getTaxValue(policy, transaction, transaction?.taxCode ?? defaultTaxCode) ??
(isMovingTransactionFromTrackExpense ? getTaxValue(policyForMovingExpenses, transaction, transaction?.taxCode ?? defaultTaxCode) : '');
const taxAmount = calculateTaxAmount(taxPercentage, taxableAmount, transaction?.currency ?? CONST.CURRENCY.USD);
const taxAmountInSmallestCurrencyUnits = convertToBackendAmount(Number.parseFloat(taxAmount.toString()));
useEffect(() => {
Expand Down Expand Up @@ -869,7 +874,7 @@ function MoneyRequestConfirmationList({
if (!transactionID || iouCategory || !shouldShowCategories || enabledCategories.length !== 1 || !isCategoryRequired) {
return;
}
setMoneyRequestCategory(transactionID, enabledCategories.at(0)?.name ?? '', policy);
setMoneyRequestCategory(transactionID, enabledCategories.at(0)?.name ?? '', policy, isMovingTransactionFromTrackExpense);
// Keep 'transaction' out to ensure that we auto select the option only once
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [shouldShowCategories, policyCategories, isCategoryRequired, policy?.id]);
Expand Down Expand Up @@ -962,6 +967,11 @@ function MoneyRequestConfirmationList({
return;
}

if (shouldShowTax && !!transaction.taxCode && !Object.keys(policy?.taxRates?.taxes ?? {}).some((key) => key === transaction.taxCode)) {
setFormError('violations.taxOutOfPolicy');
return;
}

if (isPerDiemRequest && (transaction.comment?.customUnit?.subRates ?? []).length === 0) {
setFormError('iou.error.invalidSubrateLength');
return;
Expand Down Expand Up @@ -1029,6 +1039,7 @@ function MoneyRequestConfirmationList({
isMerchantRequired,
isMerchantEmpty,
shouldDisplayFieldError,
shouldShowTax,
transaction,
policyTags,
isPerDiemRequest,
Expand Down
20 changes: 16 additions & 4 deletions src/components/MoneyRequestConfirmationListFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {getDecodedCategoryName} from '@libs/CategoryUtils';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import DistanceRequestUtils from '@libs/DistanceRequestUtils';
import {shouldShowReceiptEmptyState} from '@libs/IOUUtils';
import {isMovingTransactionFromTrackExpense, shouldShowReceiptEmptyState} from '@libs/IOUUtils';
import Navigation from '@libs/Navigation/Navigation';
import {getDestinationForDisplay, getSubratesFields, getSubratesForDisplay, getTimeDifferenceIntervals, getTimeForDisplay} from '@libs/PerDiemRequestUtils';
import {canSendInvoice, getPerDiemCustomUnit} from '@libs/PolicyUtils';
Expand Down Expand Up @@ -293,7 +293,7 @@ function MoneyRequestConfirmationListFooter({
const [outstandingReportsByPolicyID] = useOnyx(ONYXKEYS.DERIVED.OUTSTANDING_REPORTS_BY_POLICY_ID, {
canBeMissing: true,
});
const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses();
const {policyForMovingExpensesID, policyForMovingExpenses, shouldSelectPolicy} = usePolicyForMovingExpenses();

const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: emailSelector, canBeMissing: true});
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -379,11 +379,13 @@ function MoneyRequestConfirmationListFooter({

const shouldReportBeEditableFromFAB = isUnreported ? allOutstandingReports.length >= 1 : allOutstandingReports.length > 1;

const isMovingCurrentTransactionFromTrackExpense = isMovingTransactionFromTrackExpense(action);

// When creating an expense in an individual report, the report field becomes read-only
// since the destination is already determined and there's no need to show a selectable list.
const shouldReportBeEditable =
(isFromGlobalCreate && !isPerDiemRequest ? shouldReportBeEditableFromFAB : availableOutstandingReports.length > 1) && !isMoneyRequestReport(reportID, allReports);
const taxRates = policy?.taxRates ?? null;
const taxRates = policy?.taxRates ?? (isMovingCurrentTransactionFromTrackExpense ? policyForMovingExpenses?.taxRates : null);
// In Send Money and Split Bill with Scan flow, we don't allow the Merchant or Date to be edited. For distance requests, don't show the merchant as there's already another "Distance" menu item
const shouldShowDate = shouldShowSmartScanFields || isDistanceRequest;
// Determines whether the tax fields can be modified.
Expand All @@ -398,11 +400,19 @@ function MoneyRequestConfirmationListFooter({
const taxAmount = getTaxAmount(transaction, false);
const formattedTaxAmount = convertToDisplayString(taxAmount, iouCurrencyCode);
// Get the tax rate title based on the policy and transaction
const taxRateTitle = getTaxName(policy, transaction);
let taxRateTitle;
if (getTaxName(policy, transaction)) {
taxRateTitle = getTaxName(policy, transaction);
} else if (isMovingCurrentTransactionFromTrackExpense) {
taxRateTitle = getTaxName(policyForMovingExpenses, transaction);
} else {
taxRateTitle = '';
}
// Determine if the merchant error should be displayed
const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty;
const shouldDisplayDistanceRateError = formError === 'iou.error.invalidRate';
const shouldDisplayTagError = formError === 'violations.tagOutOfPolicy';
const shouldDisplayTaxRateError = formError === 'violations.taxOutOfPolicy';
const shouldDisplayCategoryError = formError === 'violations.categoryOutOfPolicy';
const shouldDisplayAttendeesError = formError === 'violations.missingAttendees';

Expand Down Expand Up @@ -769,6 +779,8 @@ function MoneyRequestConfirmationListFooter({
}}
disabled={didConfirm}
interactive={canModifyTaxFields}
brickRoadIndicator={shouldDisplayTaxRateError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={shouldDisplayTaxRateError ? translate(formError) : ''}
/>
),
shouldShow: shouldShowTax,
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function MoneyRequestView({
: convertToDisplayString(Math.abs(transactionTaxAmount ?? 0), transactionCurrency);

const taxRatesDescription = taxRates?.name;
const taxRateTitle = updatedTransaction ? getTaxName(policy, updatedTransaction) : getTaxName(policy, transaction);
const taxRateTitle = updatedTransaction ? getTaxName(policy, updatedTransaction, isExpenseUnreported) : getTaxName(policy, transaction, isExpenseUnreported);

const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction, preferredLocale) : transactionDate;
const fallbackTaxRateTitle = transaction?.taxValue;
Expand Down Expand Up @@ -395,7 +395,7 @@ function MoneyRequestView({
canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REIMBURSABLE, undefined, isChatReportArchived, undefined, transaction, moneyRequestReport, policy);
const shouldShowAttendees = shouldShowAttendeesTransactionUtils(iouType, policy);

const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest, isPerDiemRequest, isTimeRequest);
const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat || isExpenseUnreported, policy, isDistanceRequest, isPerDiemRequest, isTimeRequest);
const tripID = getTripIDFromTransactionParentReportID(parentReport?.parentReportID);
const shouldShowViewTripDetails = hasReservationList(transaction) && !!tripID;

Expand Down
39 changes: 39 additions & 0 deletions src/hooks/usePolicyForTransaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type {OnyxEntry} from 'react-native-onyx';
import {isExpenseUnreported} from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Policy, Report, Transaction} from '@src/types/onyx';
import useOnyx from './useOnyx';
import usePolicyForMovingExpenses from './usePolicyForMovingExpenses';

type UsePolicyForTransactionParams = {
/** The transaction to determine the policy for */
transaction: OnyxEntry<Transaction>;

/** The report associated with the transaction */
report: OnyxEntry<Report>;

/** The current action being performed */
action: string;

/** The type of IOU (split, track, submit, etc.) */
iouType: string;
};

type UsePolicyForTransactionResult = {
/** The policy to use for the transaction */
policy: OnyxEntry<Policy>;
};

function usePolicyForTransaction({transaction, report, action, iouType}: UsePolicyForTransactionParams): UsePolicyForTransactionResult {
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const isUnreportedExpense = isExpenseUnreported(transaction);
const isCreatingTrackExpense = action === CONST.IOU.ACTION.CREATE && iouType === CONST.IOU.TYPE.TRACK;

const [reportPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, {canBeMissing: true});
const policy = isUnreportedExpense || isCreatingTrackExpense ? policyForMovingExpenses : reportPolicy;

return {policy};
}

export default usePolicyForTransaction;
1 change: 1 addition & 0 deletions src/libs/API/parameters/TrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type TrackExpenseParams = {
reportPreviewReportActionID?: string;
optimisticReportID?: string;
optimisticReportActionID?: string;
policyID?: string;
receipt?: Receipt;
receiptState?: ValueOf<typeof CONST.IOU.RECEIPT_STATE>;
category?: string;
Expand Down
10 changes: 8 additions & 2 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

let allPolicies: OnyxCollection<Policy>;

Onyx.connect({

Check warning on line 63 in src/libs/PolicyUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
Expand Down Expand Up @@ -666,13 +666,19 @@
return policy?.type === CONST.POLICY.TYPE.TEAM;
}

function isTaxTrackingEnabled(isPolicyExpenseChat: boolean, policy: OnyxEntry<Policy>, isDistanceRequest: boolean, isPerDiemRequest = false, isTimeRequest = false): boolean {
function isTaxTrackingEnabled(
isPolicyExpenseChatOrUnreportedExpense: boolean,
policy: OnyxEntry<Policy>,
isDistanceRequest: boolean,
isPerDiemRequest = false,
isTimeRequest = false,
): boolean {
if (isPerDiemRequest || isTimeRequest) {
return false;
}
const distanceUnit = getDistanceRateCustomUnit(policy);
const customUnitID = distanceUnit?.customUnitID ?? CONST.DEFAULT_NUMBER_ID;
const isPolicyTaxTrackingEnabled = isPolicyExpenseChat && policy?.tax?.trackingEnabled;
const isPolicyTaxTrackingEnabled = isPolicyExpenseChatOrUnreportedExpense && policy?.tax?.trackingEnabled;
const isTaxEnabledForDistance = isPolicyTaxTrackingEnabled && !!customUnitID && policy?.customUnits?.[customUnitID]?.attributes?.taxEnabled;

return !!(isDistanceRequest ? isTaxEnabledForDistance : isPolicyTaxTrackingEnabled);
Expand Down
17 changes: 15 additions & 2 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ function getUpdatedTransaction({
updatedTransaction.taxCode = transactionChanges.taxCode;
}

if (Object.hasOwn(transactionChanges, 'taxValue') && typeof transactionChanges.taxCode === 'string') {
updatedTransaction.taxValue = transactionChanges.taxValue;
}

if (Object.hasOwn(transactionChanges, 'reimbursable') && typeof transactionChanges.reimbursable === 'boolean') {
updatedTransaction.reimbursable = transactionChanges.reimbursable;
}
Expand Down Expand Up @@ -2070,9 +2074,18 @@ function getWorkspaceTaxesSettingsName(policy: OnyxEntry<Policy>, taxCode: strin
/**
* Gets the name corresponding to the taxCode that is displayed to the user
*/
function getTaxName(policy: OnyxEntry<Policy>, transaction: OnyxEntry<Transaction>) {
function getTaxName(policy: OnyxEntry<Policy>, transaction: OnyxEntry<Transaction>, shouldFallbackToValue = false) {
const defaultTaxCode = getDefaultTaxCode(policy, transaction);
return Object.values(transformedTaxRates(policy, transaction)).find((taxRate) => taxRate.code === (transaction?.taxCode ?? defaultTaxCode))?.modifiedName;

// transaction?.taxCode may be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const taxRate = Object.values(transformedTaxRates(policy, transaction)).find((rate) => rate.code === (transaction?.taxCode || defaultTaxCode));

if (shouldFallbackToValue && transaction?.taxValue !== undefined && taxRate?.value !== transaction?.taxValue) {
return transaction?.taxValue;
}

return taxRate?.modifiedName;
}

type FieldsToCompare = Record<string, Array<keyof Transaction>>;
Expand Down
16 changes: 14 additions & 2 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 760 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -859,7 +859,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 862 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -873,7 +873,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 876 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -882,7 +882,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 885 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -896,7 +896,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 899 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -905,7 +905,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 908 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -915,7 +915,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 918 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -924,7 +924,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 927 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand All @@ -932,7 +932,7 @@
});

let allReportActions: OnyxCollection<OnyxTypes.ReportActions>;
Onyx.connect({

Check warning on line 935 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -1314,9 +1314,13 @@
* @param transactionID - The transaction ID
* @param category - The category name
* @param policy - The policy object, or undefined for P2P transactions where tax info should be cleared
* @param isMovingFromTrackExpense - If the expense is moved from Track Expense
*/
function setMoneyRequestCategory(transactionID: string, category: string, policy: OnyxEntry<OnyxTypes.Policy>) {
function setMoneyRequestCategory(transactionID: string, category: string, policy: OnyxEntry<OnyxTypes.Policy>, isMovingFromTrackExpense?: boolean) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {category});
if (isMovingFromTrackExpense) {
return;
}
if (!policy) {
setMoneyRequestTaxRate(transactionID, '');
setMoneyRequestTaxAmount(transactionID, null);
Expand Down Expand Up @@ -5203,6 +5207,7 @@
parentReport: OnyxEntry<OnyxTypes.Report>;
taxCode: string;
taxAmount: number;
taxValue: string;
policy: OnyxEntry<OnyxTypes.Policy>;
policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>;
policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>;
Expand All @@ -5219,6 +5224,7 @@
parentReport,
taxCode,
taxAmount,
taxValue,
policy,
policyTagList,
policyCategories,
Expand All @@ -5230,6 +5236,7 @@
const transactionChanges = {
taxCode,
taxAmount,
taxValue,
};
const {params, onyxData} = getUpdateMoneyRequestParams({
transactionID,
Expand Down Expand Up @@ -6265,7 +6272,7 @@
category,
tag,
taxCode,
taxAmount,
taxAmount: Math.abs(taxAmount),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because in some cases the amount was negative. We need to send only positive value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

billable,
policyID: chatReport.policyID,
waypoints: sanitizedWaypoints,
Expand Down Expand Up @@ -6796,6 +6803,7 @@
reportPreviewReportActionID: reportPreviewAction?.reportActionID,
optimisticReportID,
optimisticReportActionID,
policyID: policy?.id,
receipt: isFileUploadable(trackedReceipt) ? trackedReceipt : undefined,
receiptState: trackedReceipt?.state,
reimbursable,
Expand Down Expand Up @@ -8539,6 +8547,7 @@
policyTagList?: OnyxEntry<OnyxTypes.PolicyTagLists>;
policyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>;
taxCode: string;
taxValue: string;
allowNegative?: boolean;
transactions: OnyxCollection<OnyxTypes.Transaction>;
transactionViolations: OnyxCollection<OnyxTypes.TransactionViolations>;
Expand All @@ -8561,6 +8570,7 @@
policyTagList,
policyCategories,
taxCode,
taxValue,
allowNegative = false,
transactions,
transactionViolations,
Expand All @@ -8575,6 +8585,7 @@
currency,
taxCode,
taxAmount,
taxValue,
};

let data: UpdateMoneyRequestData;
Expand Down Expand Up @@ -11678,6 +11689,7 @@
companySize: introSelected?.companySize as OnboardingCompanySize,
});
}

function payMoneyRequest(
paymentType: PaymentMethodType,
chatReport: OnyxTypes.Report,
Expand Down
Loading
Loading