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.56k stars 2.9k forks source link

[HOLD for payment 2024-11-11] [$250] Approver - Existing approver settings reverts to default after upgrading workspace plan #50924

Closed IuliiaHerets closed 1 week ago

IuliiaHerets commented 1 month 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
  • Automatic offers:
    • ishpaul777 | Reviewer | 104559184
Issue OwnerCurrent Issue Owner: @joekaufmanexpensify
melvin-bot[bot] commented 1 month 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 month ago

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

IuliiaHerets commented 1 month 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 month 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 month 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 1 month ago

Reproduced.

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

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

joekaufmanexpensify commented 4 weeks ago

Pending @ishpaul777 review of proposals

ishpaul777 commented 4 weeks ago

Thanks for ping, i'll review in couple hours

joekaufmanexpensify commented 3 weeks ago

Great. TY!

ishpaul777 commented 3 weeks ago

I swear i am on it today 🙇

ishpaul777 commented 3 weeks ago

Proposal from @bernhardoj works well and LGTM!

🎀 👀 🎀 C+ reviewed

melvin-bot[bot] commented 3 weeks ago

Triggered auto assignment to @MarioExpensify, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MarioExpensify commented 3 weeks ago

Very well, proposal looks good @bernhardoj!! Thank you @ishpaul777, let's move forward.

melvin-bot[bot] commented 3 weeks ago

📣 @ishpaul777 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

bernhardoj commented 3 weeks ago

PR is ready

cc: @ishpaul777

joekaufmanexpensify commented 3 weeks ago

PR in review

melvin-bot[bot] commented 2 weeks ago

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] commented 2 weeks ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.56-9 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-11-11. :confetti_ball:

For reference, here are some details about the assignees on this issue:

melvin-bot[bot] commented 2 weeks ago

@ishpaul777 @joekaufmanexpensify The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

joekaufmanexpensify commented 2 weeks ago

Payment due next week! @ishpaul777 could you tackle checklist this week?

joekaufmanexpensify commented 1 week ago

Bumped in slack

ishpaul777 commented 1 week ago

BugZero Checklist:

Bug classification Source of bug: - [x] 1a. Result of the original design (eg. a case wasn't considered) - [ ] 1b. Mistake during implementation - [ ] 1c. Backend bug - [ ] 1z. Other: Where bug was reported: - [x] 2a. Reported on production - [ ] 2b. Reported on staging (deploy blocker) - [ ] 2c. Reported on a PR - [ ] 2z. Other: Who reported the bug: - [ ] 3a. Expensify user - [ ] 3b. Expensify employee - [ ] 3c. Contributor - [x] 3d. QA - [ ] 3z. Other:
joekaufmanexpensify commented 1 week ago

Will handle payment today

joekaufmanexpensify commented 1 week ago

Checklist is all set here. We need to pay:

joekaufmanexpensify commented 1 week ago

@ishpaul777 $250 sent and contract ended

joekaufmanexpensify commented 1 week ago

Upwork job closed.

joekaufmanexpensify commented 1 week ago

Closing as all that's left here is for @bernhardoj to request payment via NewDot. Please do this at your earliest convenience!

bernhardoj commented 1 week ago

Requested in ND.

JmillsExpensify commented 1 week ago

$250 approved for @bernhardoj