Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7983,8 +7983,8 @@ function isReportOwner(report: OnyxInputOrEntry<Report>): boolean {
return report?.ownerAccountID === currentUserPersonalDetails?.accountID;
}

function isAllowedToApproveExpenseReport(report: OnyxEntry<Report>, approverAccountID?: number): boolean {
const policy = getPolicy(report?.policyID);
function isAllowedToApproveExpenseReport(report: OnyxEntry<Report>, approverAccountID?: number, reportPolicy?: OnyxEntry<Policy> | SearchPolicy): boolean {
const policy = reportPolicy ?? getPolicy(report?.policyID);
const isOwner = (approverAccountID ?? currentUserAccountID) === report?.ownerAccountID;
return !(policy?.preventSelfApproval && isOwner);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down