Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2025-01-07] [$250] Improve/fix logic for creating a workspace during onboarding flow #53326

Closed
carlosmiceli opened this issue Nov 29, 2024 · 52 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement.

Comments

@carlosmiceli
Copy link
Contributor

carlosmiceli commented Nov 29, 2024

We want new users that are taken to the Employee Count screen to have a workspace created automatically (this is currently in place):

image

However, for signups that join via expensify.com and select either vsb or smb as signup qualifier, we want to skip actually creating a workspace at this step because that's going to be created automatically via the API during the account creation. Otherwise we'll be creating one twice. These are the corresponding vsb and smb signup options on expensify.com:

Screenshot 2024-11-29 at 4 03 39 PM

To clarify, the current onboarding flow logic for creating a workspace should still occur for any new user that's taken to the onboarding modal and does NOT have either vsb or smb as a signupQualifier. Those would be:

  • a sign-up on new.expensify.com on web/mWeb
  • a sign-up on the New Expensify mobile app
  • a sign-up on the native Expensify mobile app

Please include videos of all the possible signup cases and confirming that only one workspace is created for each. Also confirm that this bug where we created duplicate workspaces doesn't reoccur (if it's still happening). Finally, we think there may be an extreme edge case where:

  • User downloaded old version of the app
  • Signs up via web
  • Gets deep linked into the app
  • App is on old version
  • Somehow gets two workspaces.

Please include in your proposal a way to prevent this if it could occur.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021862573059516200142
  • Upwork Job ID: 1862573059516200142
  • Last Price Increase: 2024-11-29
@carlosmiceli carlosmiceli added External Added to denote the issue can be worked on by a contributor Daily KSv2 Improvement Item broken or needs improvement. labels Nov 29, 2024
@carlosmiceli carlosmiceli self-assigned this Nov 29, 2024
@melvin-bot melvin-bot bot changed the title Improve/fix logic for creating a workspace during onboarding flow [$250] Improve/fix logic for creating a workspace during onboarding flow Nov 29, 2024
Copy link

melvin-bot bot commented Nov 29, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 29, 2024
Copy link

melvin-bot bot commented Nov 29, 2024

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

@nkdengineer
Copy link
Contributor

Proposal

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

Improve/fix logic for creating a workspace during onboarding flow

What is the root cause of that problem?

This is an improvement

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

Instead of creating the policy in the employee step or auto-create a new workspace for vsb onboarding, we can only create the new workspace when the user completes the final step.

  1. We can remove the create a new workspace logic here and here

  2. In here, if the onboardingPurposeSelected is newDotManageTeam, create a new workspace via createWorkspace and then get adminsChatReportID, policyID and pass it to completeOnboarding function

let onboardingAdminsChatReportID; let onboardingPolicyID;
if (onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) {
    const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
    onboardingAdminsChatReportID =  adminsChatReportID;
    onboardingPolicyID = policyID;
};
Report.completeOnboarding(
    onboardingPurposeSelected,
    CONST.ONBOARDING_MESSAGES[onboardingPurposeSelected],
    undefined,
    undefined,
    onboardingAdminsChatReportID ?? undefined,
    onboardingPolicyID,
    undefined,
    onboardingCompanySize,
    userReportedIntegration,
);

That can make sure the workspace is only created when we complete the onboarding flow with onboardingPurposeSelected as newDotManageTeam

What alternative solutions did you explore? (Optional)

In completeOnboarding function, we can build the optimistic data for new workspace via buildPolicyData function and then add these onyx data in completeOnboarding and from the backend, we will use the onboardingPolicyID to create a new workspace.

@Shahidullah-Muffakir
Copy link
Contributor

Shahidullah-Muffakir commented Nov 29, 2024

Proposal

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

If user completed the onboarding flow using OD, two workspaces are created.

What is the root cause of that problem?

  1. if signupQualifier is VSB, we are not showing How many employees do you have? or OnboardingEmployees page, hence this useEffect is added to automatically create a workspace for it.
    // If the signupQualifier is VSB, the company size step is skip.
    // So we need to create the new workspace in the accounting step
    useEffect(() => {
    const filteredPolicies = Object.values(allPolicies ?? {}).filter(PolicyUtils.isPaidGroupPolicy);
    if (!isVsb || filteredPolicies.length > 0 || isLoadingOnyxValue(allPoliciesResult)) {
    return;
    }
    const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
    Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
    Welcome.setOnboardingPolicyID(policyID);
    }, [isVsb, allPolicies, allPoliciesResult]);
  2. if signupQualifier is SMB, it is not considered anywhere in code to skip the workspace creation, workspace is created in any case here.
    if (!onboardingPolicyID) {
    const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
    Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
    Welcome.setOnboardingPolicyID(policyID);
    }

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

  1. remove this useEffect, because it is used to create a workspace if signupQualifier is VSB

    // If the signupQualifier is VSB, the company size step is skip.
    // So we need to create the new workspace in the accounting step
    useEffect(() => {
    const filteredPolicies = Object.values(allPolicies ?? {}).filter(PolicyUtils.isPaidGroupPolicy);
    if (!isVsb || filteredPolicies.length > 0 || isLoadingOnyxValue(allPoliciesResult)) {
    return;
    }
    const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
    Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
    Welcome.setOnboardingPolicyID(policyID);
    }, [isVsb, allPolicies, allPoliciesResult]);

  2. add one more condition here in BaseOnboardingEmployees, if the signupQualifier is SMB, then don't create the workspace.
    const isSmb = onboardingValues && 'signupQualifier' in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.SMB;

    if (!onboardingPolicyID) {
    const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
    Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
    Welcome.setOnboardingPolicyID(policyID);
    }

as :
if (!onboardingPolicyID && !isSmb) {

  1. and to cover the edge case, we can add the following conditions in above line:
const filteredPolicies = Object.values(allPolicies ?? {}).filter(PolicyUtils.isPaidGroupPolicy);

as:

                  if (!onboardingPolicyID && !isSmb && filteredPolicies.length <=0 ) {

@danielrvidal
Copy link
Contributor

@thesahindia any thoughts on which proposal to go with?

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
@carlosmiceli
Copy link
Contributor Author

Waiting for proposals review.

@carlosmiceli carlosmiceli added Daily KSv2 and removed Daily KSv2 labels Dec 3, 2024
@melvin-bot melvin-bot bot removed the Overdue label Dec 3, 2024
@thesahindia
Copy link
Member

@Shahidullah-Muffakir's proposal will work for all the cases.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Dec 3, 2024

Current assignee @carlosmiceli is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@nkdengineer
Copy link
Contributor

@thesahindia I don't think the selected proposal is correct when we sign up from OldDot

  1. It redirects to NewDot and no workspace is created
  2. The employee step will be skipped if we sign with vsb or smb

So we should only create a new workspace at the final step to verify that the workspace is only created when we complete the onboarding flow.

@Shahidullah-Muffakir
Copy link
Contributor

@thesahindia I don't think the selected proposal is correct when we sign up from OldDot

  1. It redirects to NewDot and no workspace is created
  2. The employee step will be skipped if we sign with vsb or smb

So we should only create a new workspace at the final step to verify that the workspace is only created when we complete the onboarding flow.

This is the issue we are trying to solve, we don't want to create aother workspace, as mention in the OP, the api will automatically create workspace for vsb and smb

we want to skip actually creating a workspace at this step because that's going to be created automatically via the API during the account creation.

@nkdengineer
Copy link
Contributor

we want to skip actually creating a workspace at this step because that's going to be created automatically via the API during the account creation.

Actually, no workspace is created after signing up via old dot.

@nkdengineer
Copy link
Contributor

Currently, the NewDot onboarding flow is skipped for accounts created from OldDot

// Onboarding is an array or an empty object for old accounts and accounts created from OldDot
if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {
return true;
}

Then the duplicate workspace case we only need to fix is the user can create multiple workspaces at the employee step if we do not complete the onboarding and login at multiple devices.

@carlosmiceli
Copy link
Contributor Author

carlosmiceli commented Dec 3, 2024

Actually, no workspace is created after signing up via old dot.

What do you mean, can you elaborate further? Are you saying that there's no way for an OD signup to have a workspace created? There could be a case I think for an individual sign up to still go through the workspace creation, but will double check.

the NewDot onboarding flow is skipped for accounts created from OldDot

If this is true, then we need to change this. We shouldn't skip onboarding for OD signups. cc @mountiny @danielrvidal bringing you in to confirm that this is at least part of the issue besides the work here, since we were talking about this modal not showing yesterday.

@carlosmiceli
Copy link
Contributor Author

the NewDot onboarding flow is skipped for accounts created from OldDot

Let's clarify this:

  • If an OD account is migrated to ND, they should skip the onboarding.
  • ALL new OD signups that get redirected should see the onboarding.

I'll update that comment to avoid confusions.

Are we good to proceed @thesahindia or should we still evaluate some of @nkdengineer's comments?

@nkdengineer
Copy link
Contributor

What do you mean, can you elaborate further? Are you saying that there's no way for an OD signup to have a workspace created? There could be a case I think for an individual sign up to still go through the workspace creation, but will double check.

we want to skip actually creating a workspace at this step because that's going to be created automatically via the API during the account creation.

@carlosmiceli In the description, we're saying that a workspace will be created automatically via the API during the account creation. But actually, there's no workspace after the user signs from OD with vsb or smb and redirects to ND. This is a confusing description.

the NewDot onboarding flow is skipped for accounts created from OldDot

I think this is for the old account.

@carlosmiceli
Copy link
Contributor Author

there's no workspace after the user signs from OD with vsb or smb and redirects to ND

That's being worked on in the BE, but the FE needs to be ready beforehand or we will create duplicate workspaces. That's the goal of this issue.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 3, 2024
@carlosmiceli carlosmiceli added Weekly KSv2 Daily KSv2 and removed Daily KSv2 Weekly KSv2 labels Dec 23, 2024
@carlosmiceli
Copy link
Contributor Author

PR has been merged.

Copy link

melvin-bot bot commented Dec 31, 2024

@carlosmiceli, @thesahindia, @Shahidullah-Muffakir Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Dec 31, 2024
@melvin-bot melvin-bot bot changed the title [$250] Improve/fix logic for creating a workspace during onboarding flow [HOLD for payment 2025-01-07] [$250] Improve/fix logic for creating a workspace during onboarding flow Dec 31, 2024
Copy link

melvin-bot bot commented Dec 31, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 31, 2024
Copy link

melvin-bot bot commented Dec 31, 2024

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

If no regressions arise, payment will be issued on 2025-01-07. 🎊

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 7, 2025
Copy link

melvin-bot bot commented Jan 7, 2025

Issue is ready for payment but no BZ is assigned. @kadiealexander you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

Copy link

melvin-bot bot commented Jan 7, 2025

Payment Summary

Upwork Job

BugZero Checklist (@kadiealexander)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1876742690713832852/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@kadiealexander
Copy link
Contributor

@thesahindia please don't forget the checklist!

@melvin-bot melvin-bot bot added the Overdue label Jan 9, 2025
@thesahindia
Copy link
Member

thesahindia commented Jan 9, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other: Not a bug (improvement)

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other: Not a bug (improvement)

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    Link to comment: N/A

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

    Link to discussion: N/A

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

Regression Test Proposal Template

Regression Test Proposal

Test:

Test 1

  1. Sign up through OD.
  2. Select Manage expenses for a small team (1-9 employees) during signup.
  3. After being redirected to ND
  4. On the account page (Do you use any accounting software? page), select any option and click Continue.
  5. Verify that the CreateWorkspace API is not called during the onboarding flow.
  6. After completing the onboarding flow, confirm that one workspace is successfully created

Test 2

  1. Sign up through ND.
  2. On the onboarding purpose step, select Manage my team's expenses.
  3. On the Employees page (How many employees do you have? page), select any option and click Continue.
  4. On the Accounting page (Do you use any accounting software? page), select any option and click Continue.
  5. Verify that the CreateWorkspace API is called during the onboarding flow
  6. Verify that one workspace is created.

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 9, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

@carlosmiceli, @kadiealexander, @thesahindia, @Shahidullah-Muffakir Whoops! This issue is 2 days overdue. Let's get this updated quick!

@carlosmiceli
Copy link
Contributor Author

Not overdue.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 13, 2025
@kadiealexander
Copy link
Contributor

Payment summary here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement.
Projects
None yet
Development

No branches or pull requests

7 participants