Skip to content
Open
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
2c9a4f8
show rates from policyForMovingExpenses
FitseTLT Nov 12, 2025
4f385e5
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Nov 20, 2025
81c56b4
pass policyID param
FitseTLT Nov 20, 2025
20c4b84
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Nov 28, 2025
99743f5
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 1, 2025
315b26e
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 1, 2025
20fa4e7
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 2, 2025
c77d855
second part implementation
FitseTLT Dec 2, 2025
826611b
removed violation for track expenses
FitseTLT Dec 2, 2025
96782d7
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 3, 2025
11e6ce9
lint fixes
FitseTLT Dec 3, 2025
c8b655b
fix test
FitseTLT Dec 3, 2025
3429cd5
minor fixes
FitseTLT Dec 3, 2025
f95d0a4
fix lint
FitseTLT Dec 3, 2025
4a9c2e4
handled quick action navigation case
FitseTLT Dec 3, 2025
555dda3
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 5, 2025
4297392
lint fix
FitseTLT Dec 5, 2025
d0f64c1
lint fix
FitseTLT Dec 5, 2025
5040612
minor fix
FitseTLT Dec 5, 2025
1df5aa1
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 15, 2025
0600580
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 17, 2025
c4a5d1a
minor fix
FitseTLT Dec 17, 2025
ac4830b
fix lint
FitseTLT Dec 17, 2025
02ff260
Merge branch 'main' into feat-apply-policyForMovingExpenses-for-rate-…
FitseTLT Dec 31, 2025
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
7 changes: 6 additions & 1 deletion src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ function MoneyRequestConfirmationList({
setCustomUnitRateID(transactionID, lastSelectedRate);
}, [customUnitRateID, transactionID, lastSelectedRate, isDistanceRequest, isPolicyExpenseChat, isMovingTransactionFromTrackExpense]);

const mileageRate = DistanceRequestUtils.getRate({transaction, policy, policyDraft});
const mileageRate = DistanceRequestUtils.getRate({
transaction,
policy: isTrackExpense ? policyForMovingExpenses : policy,
...(isMovingTransactionFromTrackExpense && {policyForMovingExpenses}),
policyDraft,
});
const rate = mileageRate.rate;
const prevRate = usePrevious(rate);
const unit = mileageRate.unit;
Expand Down
3 changes: 2 additions & 1 deletion src/components/MoneyRequestConfirmationListFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ function MoneyRequestConfirmationListFooter({
}, [allReports, shouldUseTransactionReport, transaction?.reportID, outstandingReportID]);

const reportName = useMemo(() => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const name = getReportName(selectedReport, selectedPolicy);
if (!name) {
return isUnreported ? translate('common.none') : translate('iou.newReport');
Expand Down Expand Up @@ -526,7 +527,7 @@ function MoneyRequestConfirmationListFooter({
return;
}

if (!isPolicyExpenseChat) {
if (!isPolicyExpenseChat && (!isTrackExpense || !policyForMovingExpensesID)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this different from Category field? Can we use shouldNavigateToUpgradePath here?

Navigation.navigate(
ROUTES.MONEY_REQUEST_UPGRADE.getRoute({
action,
Expand Down
7 changes: 2 additions & 5 deletions src/components/TransactionItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
isAmountMissing,
isMerchantMissing,
isScanning,
isUnreportedAndHasInvalidDistanceRateTransaction,
} from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
Expand Down Expand Up @@ -214,8 +213,7 @@
return '';
}

const isCustomUnitOutOfPolicy = isUnreportedAndHasInvalidDistanceRateTransaction(transactionItem);
const hasFieldErrors = hasMissingSmartscanFields(transactionItem, report) || isCustomUnitOutOfPolicy;
const hasFieldErrors = hasMissingSmartscanFields(transactionItem, report);
if (hasFieldErrors) {
const amountMissing = isAmountMissing(transactionItem);
const merchantMissing = isMerchantMissing(transactionItem);
Expand All @@ -227,9 +225,8 @@
error = translate('iou.missingAmount');
} else if (merchantMissing && !isSettled(report)) {
error = translate('iou.missingMerchant');
} else if (isCustomUnitOutOfPolicy) {
error = translate('violations.customUnitOutOfPolicy');
}

return error;
}
}, [transactionItem, translate, report]);
Expand Down Expand Up @@ -549,7 +546,7 @@
</View>
),
}),
[

Check warning on line 549 in src/components/TransactionItemRow/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has a missing dependency: 'hash'. Either include it or remove the dependency array

Check warning on line 549 in src/components/TransactionItemRow/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has a missing dependency: 'hash'. Either include it or remove the dependency array
StyleUtils,
transactionItem,
shouldShowTooltip,
Expand Down
1 change: 1 addition & 0 deletions src/libs/API/parameters/TrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type TrackExpenseParams = {
waypoints?: string;
actionableWhisperReportActionID?: string;
customUnitRateID?: string;
policyID?: string;
description?: string;
distance?: number;
};
Expand Down
11 changes: 8 additions & 3 deletions src/libs/DistanceRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,14 @@
reportID,
isPolicyExpenseChat,
policy,
isTrackDistanceExpense = false,
Copy link
Member

Choose a reason for hiding this comment

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

what is the use of this param? Earlier we were dependent on isPolicyExpenseChat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use it for applying the default rate of policyForMovingExpenses on a new track distance expense. To do that we pass policyForMovingExpenses as the policy and set isTrackDistanceExpense to return the default rate. Previously we only returned a policy rate for isPolicyExpenseChat case only.

lastSelectedDistanceRates,
}: {
reportID: string | undefined;
isPolicyExpenseChat: boolean;
policy: OnyxEntry<Policy> | undefined;
lastSelectedDistanceRates?: OnyxEntry<LastSelectedDistanceRates>;
isTrackDistanceExpense?: boolean;
}): string {
let customUnitRateID: string = CONST.CUSTOM_UNITS.FAKE_P2P_ID;

Expand All @@ -310,11 +312,11 @@
return customUnitRateID;
}

if (isPolicyExpenseChat) {
if (isPolicyExpenseChat || isTrackDistanceExpense) {
const distanceUnit = Object.values(policy.customUnits ?? {}).find((unit) => unit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE);
const lastSelectedDistanceRateID = lastSelectedDistanceRates?.[policy.id];
const lastSelectedDistanceRate = lastSelectedDistanceRateID ? distanceUnit?.rates[lastSelectedDistanceRateID] : undefined;
if (lastSelectedDistanceRate?.enabled && lastSelectedDistanceRateID) {
if (!isTrackDistanceExpense && lastSelectedDistanceRate?.enabled && lastSelectedDistanceRateID) {
customUnitRateID = lastSelectedDistanceRateID;
} else {
const defaultMileageRate = getDefaultMileageRate(policy);
Expand Down Expand Up @@ -359,21 +361,24 @@
policy,
policyDraft,
useTransactionDistanceUnit = true,
policyForMovingExpenses,
}: {
transaction: OnyxEntry<Transaction>;
policy: OnyxEntry<Policy>;
policyDraft?: OnyxEntry<Policy>;
policyForMovingExpenses?: OnyxEntry<Policy>;
useTransactionDistanceUnit?: boolean;
}): MileageRate {
let mileageRates = getMileageRates(policy, true, transaction?.comment?.customUnit?.customUnitRateID);
if (isEmptyObject(mileageRates) && policyDraft) {
mileageRates = getMileageRates(policyDraft, true, transaction?.comment?.customUnit?.customUnitRateID);
}
const mileageRatesForMovingExpenses = getMileageRates(policyForMovingExpenses, true, transaction?.comment?.customUnit?.customUnitRateID);
const policyCurrency = policy?.outputCurrency ?? getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD;

Check failure on line 377 in src/libs/DistanceRequestUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`getPersonalPolicy` is deprecated. Please use ONYXKEYS.PERSONAL_POLICY_ID to find the personal policyID
const defaultMileageRate = getDefaultMileageRate(policy);
const customUnitRateID = getRateID(transaction);
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const customMileageRate = (customUnitRateID && mileageRates?.[customUnitRateID]) || defaultMileageRate;
const customMileageRate = (customUnitRateID && (mileageRates?.[customUnitRateID] ?? mileageRatesForMovingExpenses?.[customUnitRateID])) || defaultMileageRate;
const mileageRate = isCustomUnitRateIDForP2P(transaction) ? getRateForP2P(policyCurrency, transaction) : customMileageRate;
const unit = getDistanceUnit(useTransactionDistanceUnit ? transaction : undefined, mileageRate);
return {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4832,7 +4832,7 @@ function canEditFieldOfMoneyRequest(

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DISTANCE_RATE) {
// The distance rate can be modified only on the distance expense reports
return isExpenseReport(moneyRequestReport) && isDistanceRequest(transaction);
return (isExpenseReport(moneyRequestReport) || isTrackExpenseAction(reportAction)) && isDistanceRequest(transaction);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.REPORT) {
Expand Down
1 change: 1 addition & 0 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,7 @@ function getActions(
}

const transaction = isTransaction ? data[key] : undefined;

// Tracked and unreported expenses don't have a report, so we return early.
if (!report) {
return [CONST.SEARCH.ACTION_TYPES.VIEW];
Expand Down
9 changes: 1 addition & 8 deletions src/libs/TransactionPreviewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import {
isPending,
isPerDiemRequest,
isScanning,
isUnreportedAndHasInvalidDistanceRateTransaction,
} from './TransactionUtils';

const emptyPersonalDetails: OnyxTypes.PersonalDetails = {
Expand Down Expand Up @@ -277,10 +276,6 @@ function getTransactionPreviewTextAndTranslationPaths({

if (isDistanceRequest(transaction)) {
previewHeaderText = [{translationPath: 'common.distance'}];

if (RBRMessage === undefined && isUnreportedAndHasInvalidDistanceRateTransaction(transaction)) {
RBRMessage = {translationPath: 'violations.customUnitOutOfPolicy'};
}
} else if (isPerDiemRequest(transaction)) {
previewHeaderText = [{translationPath: 'common.perDiem'}];
} else if (isTransactionScanning) {
Expand Down Expand Up @@ -398,9 +393,7 @@ function createTransactionPreviewConditionals({
const shouldShowCategory = !!categoryForDisplay && isReportAPolicyExpenseChat;

const hasAnyViolations =
isUnreportedAndHasInvalidDistanceRateTransaction(transaction) ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
hasViolationsOfTypeNotice ||
!!hasViolationsOfTypeNotice ||
hasWarningTypeViolation(transaction, violations, currentUserEmail ?? '', currentUserAccountID, iouReport ?? undefined, policy) ||
hasViolation(transaction, violations, currentUserEmail ?? '', currentUserAccountID, iouReport ?? undefined, policy, true) ||
(isDistanceRequest(transaction) &&
Expand Down
1 change: 0 additions & 1 deletion src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
};

let deprecatedAllReports: OnyxCollection<Report> = {};
Onyx.connect({

Check warning on line 129 in src/libs/TransactionUtils/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 @@ -135,7 +135,7 @@
});

let deprecatedAllTransactionViolations: OnyxCollection<TransactionViolations> = {};
Onyx.connect({

Check warning on line 138 in src/libs/TransactionUtils/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) => (deprecatedAllTransactionViolations = value),
Expand Down Expand Up @@ -2545,7 +2545,6 @@
createUnreportedExpenses,
isDemoTransaction,
shouldShowViolation,
isUnreportedAndHasInvalidDistanceRateTransaction,
getTransactionViolationsOfTransaction,
hasTransactionBeenRejected,
isExpenseSplit,
Expand Down
5 changes: 4 additions & 1 deletion src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
currentDate: string | undefined;
lastSelectedDistanceRates?: OnyxEntry<OnyxTypes.LastSelectedDistanceRates>;
currentUserPersonalDetails: CurrentUserPersonalDetails;
isTrackDistanceExpense?: boolean;
hasOnlyPersonalPolicies: boolean;
};

Expand Down Expand Up @@ -753,7 +754,7 @@
};

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

Check warning on line 757 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 @@ -849,7 +850,7 @@
};

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

Check warning on line 853 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 @@ -863,7 +864,7 @@
});

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

Check warning on line 867 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 @@ -872,7 +873,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
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_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -886,7 +887,7 @@
});

let allNextSteps: NonNullable<OnyxCollection<OnyxTypes.ReportNextStepDeprecated>> = {};
Onyx.connect({

Check warning on line 890 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.NEXT_STEP,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -898,14 +899,14 @@
// `allRecentlyUsedTags` was moved here temporarily from `src/libs/actions/Policy/Tag.ts` during the `Deprecate Onyx.connect` refactor.
// All uses of this variable should be replaced with `useOnyx`.
let allRecentlyUsedTags: OnyxCollection<RecentlyUsedTags> = {};
Onyx.connect({

Check warning on line 902 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.POLICY_RECENTLY_USED_TAGS,
waitForCollectionCallback: true,
callback: (val) => (allRecentlyUsedTags = val),
});

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

Check warning on line 909 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 Down Expand Up @@ -1051,6 +1052,7 @@
policy,
personalPolicy,
isFromGlobalCreate,
isTrackDistanceExpense = false,
currentIouRequestType,
newIouRequestType,
report,
Expand Down Expand Up @@ -1094,7 +1096,7 @@
if (newIouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE || newIouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MAP || newIouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL) {
if (!isFromGlobalCreate) {
const isPolicyExpenseChat = isPolicyExpenseChatReportUtil(report) || isPolicyExpenseChatReportUtil(parentReport);
const customUnitRateID = DistanceRequestUtils.getCustomUnitRateID({reportID, isPolicyExpenseChat, policy, lastSelectedDistanceRates});
const customUnitRateID = DistanceRequestUtils.getCustomUnitRateID({reportID, isPolicyExpenseChat, isTrackDistanceExpense, policy, lastSelectedDistanceRates});
comment.customUnit = {customUnitRateID, name: CONST.CUSTOM_UNITS.NAME_DISTANCE};
} else if (hasOnlyPersonalPolicies) {
comment.customUnit = {customUnitRateID: CONST.CUSTOM_UNITS.FAKE_P2P_ID, name: CONST.CUSTOM_UNITS.NAME_DISTANCE};
Expand Down Expand Up @@ -7080,6 +7082,7 @@
createdReportActionIDForThread,
waypoints: sanitizedWaypoints,
customUnitRateID,
...(policy && customUnitRateID && customUnitRateID !== CONST.CUSTOM_UNITS.FAKE_P2P_ID && {policyID: policy?.id}),
description: parsedComment,
};
if (actionableWhisperReportActionIDParam) {
Expand Down
8 changes: 7 additions & 1 deletion src/pages/iou/request/DistanceRequestStartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePersonalPolicy from '@hooks/usePersonalPolicy';
import usePolicy from '@hooks/usePolicy';
import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses';
import usePrevious from '@hooks/usePrevious';
import useThemeStyles from '@hooks/useThemeStyles';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
Expand Down Expand Up @@ -99,6 +100,8 @@ function DistanceRequestStartPage({
const navigateBack = () => {
Navigation.closeRHPFlow();
};
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const isTrackDistanceExpense = iouType === CONST.IOU.TYPE.TRACK;

const resetIOUTypeIfChanged = useCallback(
(newIOUType: IOURequestType) => {
Expand All @@ -108,9 +111,10 @@ function DistanceRequestStartPage({
}
initMoneyRequest({
reportID,
policy,
policy: isTrackDistanceExpense ? policyForMovingExpenses : policy,
personalPolicy,
isFromGlobalCreate,
isTrackDistanceExpense,
currentIouRequestType: transaction?.iouRequestType,
newIouRequestType: newIOUType,
report,
Expand All @@ -132,6 +136,8 @@ function DistanceRequestStartPage({
currentDate,
lastSelectedDistanceRates,
currentUserPersonalDetails,
isTrackDistanceExpense,
policyForMovingExpenses,
hasOnlyPersonalPolicies,
],
);
Expand Down
14 changes: 10 additions & 4 deletions src/pages/iou/request/step/IOURequestStepDistanceManual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePersonalPolicy from '@hooks/usePersonalPolicy';
import usePolicy from '@hooks/usePolicy';
import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {
Expand Down Expand Up @@ -80,6 +81,7 @@ function IOURequestStepDistanceManual({
const [selectedTab, selectedTabResult] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.DISTANCE_REQUEST_TYPE}`, {canBeMissing: true});
const isLoadingSelectedTab = isLoadingOnyxValue(selectedTabResult);
const policy = usePolicy(report?.policyID);
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const personalPolicy = usePersonalPolicy();
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false});
const defaultExpensePolicy = useDefaultExpensePolicy();
Expand All @@ -106,7 +108,6 @@ function IOURequestStepDistanceManual({
[iouType, defaultExpensePolicy],
);

const customUnitRateID = getRateID(transaction);
const unit = DistanceRequestUtils.getRate({transaction, policy: shouldUseDefaultExpensePolicy ? defaultExpensePolicy : policy}).unit;
const distance = transaction?.comment?.customUnit?.quantity ? roundToTwoDecimalPlaces(transaction.comment.customUnit.quantity) : undefined;
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
Expand Down Expand Up @@ -208,7 +209,7 @@ function IOURequestStepDistanceManual({
participant,
},
policyParams: {
policy,
policy: policyForMovingExpenses,
},
transactionParams: {
amount: 0,
Expand All @@ -218,7 +219,12 @@ function IOURequestStepDistanceManual({
merchant: translate('iou.fieldPending'),
receipt: {},
billable: false,
customUnitRateID,
customUnitRateID: DistanceRequestUtils.getCustomUnitRateID({
reportID: report.reportID,
isTrackDistanceExpense: true,
policy: policyForMovingExpenses,
isPolicyExpenseChat: false,
}),
attendees: transaction?.comment?.attendees,
},
isASAPSubmitBetaEnabled,
Expand Down Expand Up @@ -312,12 +318,12 @@ function IOURequestStepDistanceManual({
lastSelectedDistanceRates,
backToReport,
isASAPSubmitBetaEnabled,
customUnitRateID,
navigateToConfirmationPage,
defaultExpensePolicy,
personalPolicy?.autoReporting,
transactionViolations,
currentUserPersonalDetails.accountID,
policyForMovingExpenses,
quickAction,
],
);
Expand Down
13 changes: 10 additions & 3 deletions src/pages/iou/request/step/IOURequestStepDistanceMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePersonalPolicy from '@hooks/usePersonalPolicy';
import usePolicy from '@hooks/usePolicy';
import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses';
import usePrevious from '@hooks/usePrevious';
import useShowNotFoundPageInIOUStep from '@hooks/useShowNotFoundPageInIOUStep';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -89,6 +90,7 @@ function IOURequestStepDistanceMap({
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, {canBeMissing: true});
const [transactionBackup] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`, {canBeMissing: true});
const policy = usePolicy(report?.policyID);
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const personalPolicy = usePersonalPolicy();
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false});
const defaultExpensePolicy = useDefaultExpensePolicy();
Expand Down Expand Up @@ -339,7 +341,7 @@ function IOURequestStepDistanceMap({
participant,
},
policyParams: {
policy,
policy: policyForMovingExpenses,
},
transactionParams: {
amount: 0,
Expand All @@ -350,7 +352,12 @@ function IOURequestStepDistanceMap({
billable: false,
reimbursable: true,
validWaypoints: getValidWaypoints(waypoints, true),
customUnitRateID,
customUnitRateID: DistanceRequestUtils.getCustomUnitRateID({
reportID: report.reportID,
isTrackDistanceExpense: true,
policy: policyForMovingExpenses,
isPolicyExpenseChat: false,
}),
attendees: transaction?.comment?.attendees,
},
isASAPSubmitBetaEnabled,
Expand Down Expand Up @@ -447,12 +454,12 @@ function IOURequestStepDistanceMap({
lastSelectedDistanceRates,
backToReport,
isASAPSubmitBetaEnabled,
customUnitRateID,
navigateToConfirmationPage,
personalPolicy?.autoReporting,
reportID,
transactionViolations,
currentUserPersonalDetails.accountID,
policyForMovingExpenses,
quickAction,
]);

Expand Down
5 changes: 4 additions & 1 deletion src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses';
import useShowNotFoundPageInIOUStep from '@hooks/useShowNotFoundPageInIOUStep';
import useThemeStyles from '@hooks/useThemeStyles';
import {getIOURequestPolicyID, setMoneyRequestDistanceRate, setMoneyRequestTaxAmount, setMoneyRequestTaxRate, updateMoneyRequestDistanceRate} from '@libs/actions/IOU';
Expand Down Expand Up @@ -71,7 +72,9 @@ function IOURequestStepDistanceRate({
const {isBetaEnabled} = usePermissions();
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);

const rates = DistanceRequestUtils.getMileageRates(policy, false, currentRateID);
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const isTrackExpense = iouType === CONST.IOU.TYPE.TRACK;
const rates = DistanceRequestUtils.getMileageRates(isTrackExpense ? policyForMovingExpenses : policy, false, currentRateID);
const sortedRates = useMemo(() => Object.values(rates).sort((a, b) => localeCompare(a.name ?? '', b.name ?? '')), [rates, localeCompare]);

const navigateBack = () => {
Expand Down
Loading
Loading