Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.48k stars 2.83k forks source link

[$250] Approver - Existing approver settings reverts to default after upgrading workspace plan #50924

Open IuliiaHerets opened 1 day ago

IuliiaHerets commented 1 day ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.49-1 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+kh081006@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Workflows.
  3. Enable Add approvals.
  4. Click on the existing approval workflow.
  5. Click Approver.
  6. Select another member as approver and save it.
  7. Click Additional approver.
  8. Upgrade the plan.
  9. Click Got it, thanks.

Expected Result:

The existing approver settings in Step 6 will be preserved.

Actual Result:

The existing approver settings in Step 6 reverts to default after upgrading workspace plan.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/0ebb8d1c-91f2-428d-b2a0-4b1cbb47ed7a

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021847030936559806669
  • Upwork Job ID: 1847030936559806669
  • Last Price Increase: 2024-10-17
Issue OwnerCurrent Issue Owner: @ishpaul777
melvin-bot[bot] commented 1 day ago

Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

IuliiaHerets commented 1 day ago

We think that this bug might be related to #wave-control

IuliiaHerets commented 1 day ago

@joekaufmanexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

bernhardoj commented 1 day ago

Edited by proposal-police: This proposal was edited at 2024-10-16 17:02:28 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Edit to the approval workflow is reset after upgrading the workspace from the additional approver flow.

What is the root cause of that problem?

When we go back from the upgrade page, we will call dismissModal which will dismiss the whole RHP including the ongoing edit approval flow. https://github.com/Expensify/App/blob/19b489c8e51a125980c598849a64becf51bc2e6e/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx#L98-L101

Then, we call goBack which navigates to the backTo params, in our case, the edit approval flow. https://github.com/Expensify/App/blob/19b489c8e51a125980c598849a64becf51bc2e6e/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx#L39-L46

Because the page is closed and then reopened, the flow is restarted.

What changes do you think we should make in order to solve the problem?

Don't always call dismissModal. For the approval feature, just go back and navigate with the fallback route. For all other existing cases, keep the dismissModal to not change the other existing behavior.

switch (feature.id) {
    case CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.id:
        Navigation.goBack();
        if (route.params.backTo) {
            Navigation.navigate(route.params.backTo);
        }
        return;
    case CONST.UPGRADE_FEATURE_INTRO_MAPPING.reportFields.id:
    case CONST.UPGRADE_FEATURE_INTRO_MAPPING.rules.id:
    case CONST.UPGRADE_FEATURE_INTRO_MAPPING.companyCards.id:
        Navigation.dismissModal();
        return Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID));
    default:
        Navigation.dismissModal();
        return route.params.backTo ? Navigation.navigate(route.params.backTo) : Navigation.goBack();
}

Then, we can remove the dismissModal from here. https://github.com/Expensify/App/blob/19b489c8e51a125980c598849a64becf51bc2e6e/src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx#L99-L111

nkdengineer commented 1 day ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

The existing approver settings in Step 6 reverts to default after upgrading workspace plan.

What is the root cause of that problem?

After calling the UpgradeToCorporate function, we have updated the policy type and the Workflow.setApprovalWorkflow function will be called in this useEffect => it has reverted to default approver

https://github.com/Expensify/App/blob/fd2e0cb1c0578f8d3252e2eccfb35fdeb55db1bd/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx#L105-L113

What changes do you think we should make in order to solve the problem?

We will not reset the approval workflow when the policy type changes.

    const policyType = policy?.type;
    const previousType = usePrevious(policy?.type);

   if(policyType !== previousType){
            Workflow.setApprovalWorkflow({
                ...currentApprovalWorkflow,
                availableMembers: [...currentApprovalWorkflow.members, ...defaultWorkflowMembers],
                usedApproverEmails,
                action: CONST.APPROVAL_WORKFLOW.ACTION.EDIT,
                isLoading: false,
                errors: null,
            });
        }

What alternative solutions did you explore? (Optional)

joekaufmanexpensify commented 10 hours ago

Reproduced.

melvin-bot[bot] commented 10 hours ago

Job added to Upwork: https://www.upwork.com/jobs/~021847030936559806669

melvin-bot[bot] commented 10 hours ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ishpaul777 (External)