Skip to content

Commit

Permalink
Fixing the approval rules inside the optimistic rules
Browse files Browse the repository at this point in the history
  • Loading branch information
abzokhattab committed Dec 7, 2024
1 parent 6a7b207 commit f8f5c02
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/libs/actions/Policy/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,7 @@ function removeMembers(accountIDs: number[], policyID: string) {
failureMembersState[email] = {errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.people.error.genericRemove')};
});

const approvalRules: ApprovalRule[] = policy?.rules?.approvalRules ?? [];
const optimisticApprovalRules: ApprovalRule[] = [];

Object.keys(policy?.employeeList ?? {}).forEach((employeeEmail) => {
approvalRules.forEach((rule) => {
if (employeeEmail === rule?.approver) {
return;
}
optimisticApprovalRules.push(rule);
});

const employee = policy?.employeeList?.[employeeEmail];
optimisticMembersState[employeeEmail] = optimisticMembersState[employeeEmail] ?? {};
failureMembersState[employeeEmail] = failureMembersState[employeeEmail] ?? {};
Expand Down Expand Up @@ -342,6 +332,9 @@ function removeMembers(accountIDs: number[], policyID: string) {
}
});

const approvalRules: ApprovalRule[] = policy?.rules?.approvalRules ?? [];
const optimisticApprovalRules = approvalRules.filter((rule) => !emailList.includes(rule?.approver ?? ''));

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down

0 comments on commit f8f5c02

Please sign in to comment.