@@ -15,7 +15,7 @@ import usePolicy from '@hooks/usePolicy';
1515import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses' ;
1616import useReportTransactions from '@hooks/useReportTransactions' ;
1717import Navigation from '@libs/Navigation/Navigation' ;
18- import { getPersonalPolicy , isPolicyAdmin } from '@libs/PolicyUtils' ;
18+ import { canSubmitPerDiemExpenseFromWorkspace , getPersonalPolicy , isPolicyAdmin } from '@libs/PolicyUtils' ;
1919import { canAddTransaction , getOutstandingReportsForUser , getPolicyName , isIOUReport , isOpenReport , isReportOwner , isSelfDM , sortOutstandingReportsBySelected } from '@libs/ReportUtils' ;
2020import CONST from '@src/CONST' ;
2121import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -40,6 +40,7 @@ type Props = {
4040 isUnreported ?: boolean ;
4141 shouldShowNotFoundPage ?: boolean ;
4242 createReport ?: ( ) => void ;
43+ isPerDiemRequest ?: boolean ;
4344} ;
4445
4546const policyIdSelector = ( policy : OnyxEntry < Policy > ) => policy ?. id ;
@@ -57,10 +58,12 @@ function IOURequestEditReportCommon({
5758 isUnreported,
5859 shouldShowNotFoundPage : shouldShowNotFoundPageFromProps ,
5960 createReport,
61+ isPerDiemRequest,
6062} : Props ) {
6163 const { translate, localeCompare} = useLocalize ( ) ;
6264 const { options} = useOptionsList ( ) ;
6365 const [ outstandingReportsByPolicyID ] = useOnyx ( ONYXKEYS . DERIVED . OUTSTANDING_REPORTS_BY_POLICY_ID , { canBeMissing : true } ) ;
66+ const [ allPolicies ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { canBeMissing : true } ) ;
6467 const currentUserPersonalDetails = useCurrentUserPersonalDetails ( ) ;
6568 const [ selectedReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ selectedReportID } ` , { canBeMissing : true } ) ;
6669 const reportOwnerAccountID = useMemo ( ( ) => selectedReport ?. ownerAccountID ?? currentUserPersonalDetails . accountID , [ selectedReport , currentUserPersonalDetails . accountID ] ) ;
@@ -130,6 +133,13 @@ function IOURequestEditReportCommon({
130133 . sort ( ( report1 , report2 ) => sortOutstandingReportsBySelected ( report1 , report2 , selectedReportID , localeCompare ) )
131134 . filter ( ( report ) => ! debouncedSearchValue || report ?. reportName ?. toLowerCase ( ) . includes ( debouncedSearchValue . toLowerCase ( ) ) )
132135 . filter ( ( report ) : report is NonNullable < typeof report > => report !== undefined )
136+ . filter ( ( report ) => {
137+ if ( isPerDiemRequest && report ?. policyID ) {
138+ const policy = allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ report . policyID } ` ] ;
139+ return canSubmitPerDiemExpenseFromWorkspace ( policy ) ;
140+ }
141+ return true ;
142+ } )
133143 . filter ( ( report ) => canAddTransaction ( report ) )
134144 . map ( ( report ) => {
135145 const matchingOption = options . reports . find ( ( option ) => option . reportID === report . reportID ) ;
@@ -144,7 +154,7 @@ function IOURequestEditReportCommon({
144154 policyID : matchingOption ?. policyID ?? report . policyID ,
145155 } ;
146156 } ) ;
147- } , [ outstandingReportsByPolicyID , debouncedSearchValue , expenseReports , selectedReportID , options . reports , localeCompare ] ) ;
157+ } , [ outstandingReportsByPolicyID , debouncedSearchValue , expenseReports , selectedReportID , options . reports , localeCompare , allPolicies , isPerDiemRequest ] ) ;
148158
149159 const navigateBack = ( ) => {
150160 Navigation . goBack ( backTo ) ;
0 commit comments