@@ -17,9 +17,10 @@ import useThemeStyles from '@hooks/useThemeStyles';
1717import { fetchUnreportedExpenses } from '@libs/actions/UnreportedExpenses' ;
1818import interceptAnonymousUser from '@libs/interceptAnonymousUser' ;
1919import type { AddUnreportedExpensesParamList } from '@libs/Navigation/types' ;
20+ import { canSubmitPerDiemExpenseFromWorkspace , getPerDiemCustomUnit } from '@libs/PolicyUtils' ;
2021import { isIOUReport } from '@libs/ReportUtils' ;
2122import { shouldRestrictUserBillableActions } from '@libs/SubscriptionUtils' ;
22- import { createUnreportedExpenseSections } from '@libs/TransactionUtils' ;
23+ import { createUnreportedExpenseSections , isPerDiemRequest } from '@libs/TransactionUtils' ;
2324import Navigation from '@navigation/Navigation' ;
2425import type { PlatformStackScreenProps } from '@navigation/PlatformStackNavigation/types' ;
2526import { convertBulkTrackedExpensesToIOU , startMoneyRequest } from '@userActions/IOU' ;
@@ -53,7 +54,22 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) {
5354 if ( ! transactions ) {
5455 return [ ] ;
5556 }
56- return Object . values ( transactions || { } ) . filter ( ( item ) => item ?. reportID === CONST . REPORT . UNREPORTED_REPORT_ID || item ?. reportID === '' ) ;
57+ return Object . values ( transactions || { } ) . filter ( ( item ) => {
58+ const isUnreported = item ?. reportID === CONST . REPORT . UNREPORTED_REPORT_ID || item ?. reportID === '' ;
59+ if ( ! isUnreported ) {
60+ return false ;
61+ }
62+
63+ if ( isPerDiemRequest ( item ) ) {
64+ // Only show per diem expenses if the target workspace has per diem enabled and the per diem expense was created in the same workspace
65+ const workspacePerDiemUnit = getPerDiemCustomUnit ( policy ) ;
66+ const perDiemCustomUnitID = item ?. comment ?. customUnit ?. customUnitID ;
67+
68+ return canSubmitPerDiemExpenseFromWorkspace ( policy ) && ( ! perDiemCustomUnitID || perDiemCustomUnitID === workspacePerDiemUnit ?. customUnitID ) ;
69+ }
70+
71+ return true ;
72+ } ) ;
5773 }
5874
5975 const [ transactions = getEmptyArray < Transaction > ( ) ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , {
0 commit comments