diff --git a/src/pages/AddUnreportedExpense.tsx b/src/pages/AddUnreportedExpense.tsx index 376db90e9306..3178a806be21 100644 --- a/src/pages/AddUnreportedExpense.tsx +++ b/src/pages/AddUnreportedExpense.tsx @@ -17,9 +17,10 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {fetchUnreportedExpenses} from '@libs/actions/UnreportedExpenses'; import interceptAnonymousUser from '@libs/interceptAnonymousUser'; import type {AddUnreportedExpensesParamList} from '@libs/Navigation/types'; +import {canSubmitPerDiemExpenseFromWorkspace, getPerDiemCustomUnit} from '@libs/PolicyUtils'; import {isIOUReport} from '@libs/ReportUtils'; import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; -import {createUnreportedExpenseSections} from '@libs/TransactionUtils'; +import {createUnreportedExpenseSections, isPerDiemRequest} from '@libs/TransactionUtils'; import Navigation from '@navigation/Navigation'; import type {PlatformStackScreenProps} from '@navigation/PlatformStackNavigation/types'; import {convertBulkTrackedExpensesToIOU, startMoneyRequest} from '@userActions/IOU'; @@ -53,7 +54,22 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) { if (!transactions) { return []; } - return Object.values(transactions || {}).filter((item) => item?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID || item?.reportID === ''); + return Object.values(transactions || {}).filter((item) => { + const isUnreported = item?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID || item?.reportID === ''; + if (!isUnreported) { + return false; + } + + if (isPerDiemRequest(item)) { + // Only show per diem expenses if the target workspace has per diem enabled and the per diem expense was created in the same workspace + const workspacePerDiemUnit = getPerDiemCustomUnit(policy); + const perDiemCustomUnitID = item?.comment?.customUnit?.customUnitID; + + return canSubmitPerDiemExpenseFromWorkspace(policy) && (!perDiemCustomUnitID || perDiemCustomUnitID === workspacePerDiemUnit?.customUnitID); + } + + return true; + }); } const [transactions = getEmptyArray()] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {