Skip to content

Commit

Permalink
fix: filter approvers from submit to members page if preventSelfAppro…
Browse files Browse the repository at this point in the history
…val is true.

Signed-off-by: krishna2323 <[email protected]>
  • Loading branch information
Krishna2323 committed Dec 12, 2024
1 parent 764e286 commit 55a9bb3
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function WorkspaceWorkflowsApprovalsExpensesFromPage({policy, isLoadingReportDat
);
}, [approvalWorkflow?.members, policy?.employeeList, translate]);

const approversEmail = useMemo(() => approvalWorkflow?.approvers.map((member) => member?.email), [approvalWorkflow?.approvers]);
const sections: MembersSection[] = useMemo(() => {
const members: SelectionListMember[] = [...selectedMembers];

Expand All @@ -107,7 +108,9 @@ function WorkspaceWorkflowsApprovalsExpensesFromPage({policy, isLoadingReportDat
rightElement: isAdmin ? <Badge text={translate('common.admin')} /> : undefined,
};
})
.filter((member) => !selectedMembers.some((selectedOption) => selectedOption.login === member.login));
.filter(
(member) => (!policy?.preventSelfApproval || !approversEmail?.includes(member.login)) && !selectedMembers.some((selectedOption) => selectedOption.login === member.login),
);

members.push(...availableMembers);
}
Expand All @@ -128,7 +131,7 @@ function WorkspaceWorkflowsApprovalsExpensesFromPage({policy, isLoadingReportDat
shouldShow: true,
},
];
}, [approvalWorkflow?.availableMembers, debouncedSearchTerm, policy?.employeeList, selectedMembers, translate]);
}, [approvalWorkflow?.availableMembers, debouncedSearchTerm, policy?.preventSelfApproval, policy?.employeeList, selectedMembers, translate, approversEmail]);

const goBack = useCallback(() => {
let backTo;
Expand Down

0 comments on commit 55a9bb3

Please sign in to comment.