Skip to content

Commit

Permalink
Merge pull request #47955 from bernhardoj/fix/47723-approver-field-di…
Browse files Browse the repository at this point in the history
…sappears-after-unselecting

Fix approver field disappears after deselecting the user
  • Loading branch information
mountiny authored Aug 27, 2024
2 parents afc6775 + 9653b57 commit b2cd099
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function ApprovalWorkflowEditor({approvalWorkflow, removeApprovalWorkflow, polic
const styles = useThemeStyles();
const theme = useTheme();
const {translate, toLocaleOrdinal} = useLocalize();
const approverCount = approvalWorkflow.approvers.length;

const approverDescription = useCallback(
(index: number) =>
approvalWorkflow.approvers.length > 1 ? `${toLocaleOrdinal(index + 1, true)} ${translate('workflowsPage.approver').toLowerCase()}` : `${translate('workflowsPage.approver')}`,
[approvalWorkflow.approvers.length, toLocaleOrdinal, translate],
(index: number) => (approverCount > 1 ? `${toLocaleOrdinal(index + 1, true)} ${translate('workflowsPage.approver').toLowerCase()}` : `${translate('workflowsPage.approver')}`),
[approverCount, toLocaleOrdinal, translate],
);

const members = useMemo(() => {
Expand Down Expand Up @@ -94,15 +94,15 @@ function ApprovalWorkflowEditor({approvalWorkflow, removeApprovalWorkflow, polic

// User should be allowed to add additional approver only if they upgraded to Control Plan, otherwise redirected to the Upgrade Page
const addAdditionalApprover = useCallback(() => {
if (!PolicyUtils.isControlPolicy(policy)) {
if (!PolicyUtils.isControlPolicy(policy) && approverCount > 0) {
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.alias, Navigation.getActiveRoute()));
return;
}
Navigation.navigate(
ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_APPROVER.getRoute(policyID, approvalWorkflow.approvers.length, ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(policyID)),
ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_APPROVER.getRoute(policyID, approverCount, ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(policyID)),
CONST.NAVIGATION.ACTION_TYPE.PUSH,
);
}, [approvalWorkflow.approvers.length, policy, policyID]);
}, [approverCount, policy, policyID]);

return (
<ScrollView
Expand Down Expand Up @@ -156,7 +156,7 @@ function ApprovalWorkflowEditor({approvalWorkflow, removeApprovalWorkflow, polic
})}

<MenuItemWithTopDescription
description={translate('workflowsCreateApprovalsPage.additionalApprover')}
description={approverCount > 0 ? translate('workflowsCreateApprovalsPage.additionalApprover') : translate('workflowsPage.approver')}
onPress={addAdditionalApprover}
shouldShowRightIcon
wrapperStyle={styles.sectionMenuItemTopDescription}
Expand Down

0 comments on commit b2cd099

Please sign in to comment.