diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 73721d094ebe..e0c0cf28dcf2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7983,8 +7983,8 @@ function isReportOwner(report: OnyxInputOrEntry): boolean { return report?.ownerAccountID === currentUserPersonalDetails?.accountID; } -function isAllowedToApproveExpenseReport(report: OnyxEntry, approverAccountID?: number): boolean { - const policy = getPolicy(report?.policyID); +function isAllowedToApproveExpenseReport(report: OnyxEntry, approverAccountID?: number, reportPolicy?: OnyxEntry | SearchPolicy): boolean { + const policy = reportPolicy ?? getPolicy(report?.policyID); const isOwner = (approverAccountID ?? currentUserAccountID) === report?.ownerAccountID; return !(policy?.preventSelfApproval && isOwner); } diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 29537b9c8368..3fe5faef7299 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -292,7 +292,7 @@ function getAction(data: OnyxTypes.SearchResults['data'], key: string): SearchTr return CONST.SEARCH.ACTION_TYPES.PAY; } - if (IOU.canApproveIOU(report, policy)) { + if (IOU.canApproveIOU(report, policy) && ReportUtils.isAllowedToApproveExpenseReport(report, undefined, policy)) { return CONST.SEARCH.ACTION_TYPES.APPROVE; } diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index 56ae9cc62379..1d7abe7d63cf 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -222,6 +222,9 @@ type SearchPolicy = { /** The auto reimbursement limit */ limit: number; }; + + /** Whether the self approval or submitting is enabled */ + preventSelfApproval?: boolean; }; /** Model of transaction search result */