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
2.99k stars 2.5k forks source link

[Guided Setup Stage 2] Multiple workspaces are created when navigating back and changing the business name #41838

Open izarutskaya opened 1 week ago

izarutskaya commented 1 week 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: v1.4.71-0 Reproducible in staging?: Y Reproducible in production?: N Found when validating PR : https://github.com/Expensify/App/pull/41593 Email or phone of affected tester (no customers): shussain+acjhn1@applausemail.com Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team

Action Performed:

  1. Sign up with a new account
  2. Click Manage my team's Expenses in the onboarding modal
  3. Verify that the next question you're asked is for your business name
  4. Enter your business name
  5. Verify that the next question you're asked is for your personal name
  6. Click back button and change business name
  7. Notice in background multiple workspace created

Expected Result:

Changing the business name after navigating back should not create multiple workspaces; it should only update the existing workspace with the new name

Actual Result:

Multiple workspaces are created when navigating back and changing the business name

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

https://github.com/Expensify/App/assets/115492554/76a878c0-0ca6-40b6-90a6-1c413e59571f

View all open jobs on GitHub

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @amyevans (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] commented 1 week ago

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open Staging deploy checklist to see the list of PRs included in this release, then work quickly on the following:

  1. If you find which PR caused the issue/bug, you can reassign it to the person responsible for it.
    • If the author is OOO or won’t get online before the daily deploy is due, you are responsible for finding the best fix/path forward. Don’t hesitate to ask for help!
  2. Try to reproduce the issue, if the bug is on production, remove the DeployBlocker label but stay assigned to fix it (or find out which PR broke it to get help from the author).
    • You can adjust the urgency of the issue to better represent the gravity of the bug.
    • If the issue is super low priority, feel free to un-assign yourself.
    • Be careful with PHP warnings, sometimes it is more complex than just adding a null coalescing operator as they might be uncovering some bigger bug.
    • If it was a one-off issue that requires no action (for example, Bedrock was down or it is a duplicated issue), you can close it.

Remember rule #2: Never un-assign yourself from a real DeployBlocker unless you are 100% sure someone else is assigned and will take care of it.

melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @puneetlath (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.

github-actions[bot] commented 1 week ago

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.
izarutskaya commented 1 week ago

@puneetlath 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.

izarutskaya commented 1 week ago

We think this issue might be related to the #collect project.

izarutskaya commented 1 week ago

Production

https://github.com/Expensify/App/assets/115492554/fdb09279-3ce2-4678-864c-9711ef8b744d

amyevans commented 1 week ago

This is an unintended side effect of the changes in https://github.com/Expensify/App/pull/41593 - @francoisl @DylanDylann @ishpaul777 shall we revert or are one of you available to get a fix PR together soon?

ishpaul777 commented 1 week ago

Agree that this is sideeffect but this was this expected behviour in the issue

Screenshot 2024-05-08 at 8 38 47 PM

i can't think of any other solution than delaying a workspace creation until the flow is completed, mean we only call createWorkspace at the end of flow.

cc @trjExpensify

trjExpensify commented 1 week ago

@mountiny @rezkiy37 might have some ideas as well. I think it's a bit of an edge case to confirm the business name and then go back and change it, so I'm not sure I'd call it a deploy blocker per se, but we should see what we can do about it.

mountiny commented 1 week ago

Discussed with Tom and I think this does not have to be a deploy blocker as its a rare flow. The UX is not great, but not a blocker.

If we want to keep this behaviour of creating a workspace before the flow is completed (that is to be able to create correct guide calendar link in the message), we should probably consider adding some flag to the optimistic policy data so that when user goes back in the flow, we would not call CreateWorkspace but API to update the existing workspace name instead

amyevans commented 1 week ago

Sounds good, I'll demote it. I agree the approach would be to call UpdateWorkspaceGeneralSettings with the new name if the user navigated back and then forward again, but I haven't looked at the code to see how achievable that is. @francoisl mind if I reassign you as CME since you've got more context?

cretadn22 commented 1 week ago

Proposal

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

Multiple instances of the workspace are being created

What is the root cause of that problem?

https://github.com/Expensify/App/blob/e0b6a06d2f34f35cda96ccc4d05252ede111c732/src/pages/OnboardingWork/BaseOnboardingWork.tsx#L44

We consistently generate a fresh workspace upon finishing the business name page during the onboarding process

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

As @amyevans's suggestion, I propose adding a new field to ONYX called "onboardingPolicyID"

https://github.com/Expensify/App/blob/e0b6a06d2f34f35cda96ccc4d05252ede111c732/src/pages/OnboardingWork/BaseOnboardingWork.tsx#L44

And we'll configure the onboardingPolicyID accordingly.

if (!onboardingPolicyID) { // Get from ONYX
  const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, work);
  Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
  Welcome.setOnboardingPolicyID(policyID);
}
Policy.updateGeneralSettings(onboardingPolicyID, work, onboardingPolicy.outputCurrency ||  CONST.CURRENCY.USD)

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

francoisl commented 1 week ago

Yes that works for me. As Vit said, we need to keep the CreateWorkspace API call where it is now rather than at the end of the flow, so that we can have the user's assigned guide's calendar link for the "Meet your setup specialist" task.


@cretadn22 I believe you're missing the name parameter when you're calling updateGeneralSettings in your proposal. @ishpaul777 I'm going to assign you as C+ if that's ok, since you already have context on the issue.

cretadn22 commented 1 week ago

@francoisl My mistake. I've made the update.

ishpaul777 commented 1 week ago

Proposal from @cretadn22 LGTM!

🎀 👀 🎀 C+ reviewed

melvin-bot[bot] commented 1 week ago

Current assignees @puneetlath and @francoisl are eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

puneetlath commented 1 week ago

@francoisl I'll let you take CME on this one.

trjExpensify commented 4 days ago

PR merged today!