Skip to content

Commit 5c8aa37

Browse files
MelvinBotsituchan
andcommitted
Apply review suggestions to approval workflow comments
Co-authored-by: Situ Chandra Shil <situchan@users.noreply.github.com>
1 parent c7ec704 commit 5c8aa37

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

‎src/hooks/useApprovalWorkflows.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@ type UseApprovalWorkflowsResult = {
4545
};
4646

4747
/**
48-
* Derives a workspace's approval workflows from the source of truth (the policy employees, or the
49-
* approval-workflow rules when the `MULTIPLE_APPROVERS` beta is on) and reports whether the workspace actually
50-
* has a custom (advanced) approval workflow.
48+
* Derives approval workflows from policy employees or approval rules when `MULTIPLE_APPROVERS` is enabled.
5149
*
52-
* Prefer `isAdvanceApproval` over reading `policy.approvalMode === ADVANCED`: the stored flag is written
53-
* optimistically by many code paths and drifts from the real workflow structure, so it can say ADVANCED for a
54-
* workspace with no custom workflow (e.g. right after an upgrade) and stay BASIC for one that has several.
50+
* Prefer `isAdvanceApproval` over `policy.approvalMode`: the stored value is updated optimistically and can drift from the actual workflow structure.
5551
*/
5652
function useApprovalWorkflows(policy: OnyxEntry<Policy>): UseApprovalWorkflowsResult {
5753
const policyID = policy?.id;

‎src/pages/workspace/members/WorkspaceInviteMessageComponent.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,8 @@ function WorkspaceInviteMessageComponent({
124124
const approverDetails = usePersonalDetailByLogin(workspaceInviteApproverDraft);
125125
const employeePersonalDetails = usePersonalDetailsByLogins(Object.keys(policy?.employeeList ?? {}));
126126

127-
// Derive whether a custom approval workflow exists instead of trusting `policy.approvalMode`: that flag is
128-
// written optimistically by several paths and drifts from the real workflow structure, so it can say ADVANCED
129-
// for a freshly upgraded workspace with no custom workflow, and stay BASIC for one that has several.
130-
// A Dynamic External Workflow set to hide people keeps the approval workflows out of the customer's hands, so
131-
// there is no approver for them to pick here either.
127+
// `approvalMode` can drift from the actual workflow structure because it is updated optimistically.
128+
// Dynamic external workflows that hide people also have no selectable approver.
132129
const {isAdvanceApproval, rulesCollection} = useApprovalWorkflows(policy);
133130
const shouldShowApproverRow = isAdvanceApproval && !!policy?.areWorkflowsEnabled && !shouldHideDynamicExternalWorkflowPeople(policy);
134131

‎tests/unit/useApprovalWorkflowsTest.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const buildPolicy = (policy: Partial<Policy>): Policy => ({
4545
...policy,
4646
});
4747

48-
/** Build the index-keyed object shape the rules API uses for lists */
48+
/** Build the index-keyed object shape, the rules API uses for lists */
4949
const indexMap = <T,>(...values: T[]): Record<string, T> => Object.fromEntries(values.map((value, index) => [String(index), value]));
5050

5151
/**

0 commit comments

Comments
 (0)