Skip to content

[BZ check] [$250] Workspace - All workspaces are created with the same name as "my group workspace" #63384

Closed

Description

@vincdargento

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: v9.1.56-9
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): +917998977868
Issue reported by: Applause Internal Team
Device used: Redminote 10s android 13 phone
App Component: Workspace Settings

Action Performed:

Go to https://staging.new.expensify.com/home
2. Login with a new phone number ( no expensify account)
3. In onboarding select managey team expenses - 1-10 - none and complete the flow
4. Create a new workspace
5. Go to workspace list
6. Tap add new workspace
7. Repeat step 6

Expected Result:

All workspaces must not be created in same name as "my group workspace".

Actual Result:

All workspaces are created in same name as "my group workspace".

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021930071819863605009
  • Upwork Job ID: 1930071819863605009
  • Last Price Increase: 2025-06-04
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 3, 2025
  2. melvin-bot commented on Jun 3, 2025

    @melvin-bot

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

  3. ganzz4 commented on Jun 3, 2025

    @ganzz4
    Contributor

    Proposal

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

    The issue is that when a user signs up with a phone number (no Expensify account) and creates multiple workspaces, all workspaces are created with the same name "My Group Workspace" instead of having unique names with incrementing numbers like "My Group Workspace 1", "My Group Workspace 2", etc.

    What is the root cause of that problem?

    The root cause lies in the generateDefaultWorkspaceName function in src/libs/actions/Policy/Policy.ts.

    When the user has an SMS domain email (i.e., registered with a phone number), the function returns a static string "My Group Workspace" without checking for duplicates.

    Unlike the logic for regular email domains — where the function checks existing workspace names and appends a number if needed — the SMS path lacks this check:

    if (`@${domain}` === CONST.SMS.DOMAIN) {
    return translateLocal('workspace.new.myGroupWorkspace');
    }

    Here is how the logic works for regular email domains:

    if (isEmptyObject(allPolicies)) {
    return translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace});
    }
    // find default named workspaces and increment the last number
    const escapedName = escapeRegExp(displayNameForWorkspace);
    const workspaceTranslations = CONST.LANGUAGES.map((lang) => translate(lang, 'workspace.common.workspace')).join('|');
    const workspaceRegex = new RegExp(`^(?=.*${escapedName})(?:.*(?:${workspaceTranslations})\\s*(\\d+)?)`, 'i');
    const workspaceNumbers = Object.values(allPolicies)
    .map((policy) => workspaceRegex.exec(policy?.name ?? ''))
    .filter(Boolean) // Remove null matches
    .map((match) => Number(match?.[1] ?? '0'));
    const lastWorkspaceNumber = workspaceNumbers.length > 0 ? Math.max(...workspaceNumbers) : undefined;
    return translateLocal('workspace.new.workspaceName', {userName: displayNameForWorkspace, workspaceNumber: lastWorkspaceNumber !== undefined ? lastWorkspaceNumber + 1 : undefined});

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

    We should update the SMS domain logic in generateDefaultWorkspaceName to follow the same pattern used for regular emails. That is: check for existing workspaces named "My Group Workspace" and append an incremented number if needed.

        if (`@${domain}` === CONST.SMS.DOMAIN) {
            const myGroupWorkspaceName = translateLocal('workspace.new.myGroupWorkspace');
            
            if (isEmptyObject(allPolicies)) {
                return myGroupWorkspaceName;
            }
            
            // Use the same pattern as for regular email domains
            const escapedName = escapeRegExp(myGroupWorkspaceName);
            const workspaceRegex = new RegExp(`^${escapedName}(?:\\s*(\\d+))?$`, 'i');
            
            const workspaceNumbers = Object.values(allPolicies)
                .map((policy) => workspaceRegex.exec(policy?.name ?? ''))
                .filter(Boolean) // Remove null matches
                .map((match) => Number(match?.[1] ?? '0'));
            
            const lastWorkspaceNumber = workspaceNumbers.length > 0 ? Math.max(...workspaceNumbers) : undefined;
            
            return lastWorkspaceNumber !== undefined 
                ? `${myGroupWorkspaceName} ${lastWorkspaceNumber + 1}` 
                : myGroupWorkspaceName;
        }

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • A test that verifies SMS domain users get incrementing workspace names:
    • A test that ensures the fallback to the base name if no matching workspaces exist.

    What alternative solutions did you explore? (Optional)

  4. ganzz4 commented on Jun 3, 2025

    @ganzz4
    Contributor

    I've recorded a quick demo video showing the fix in action:

    fix.mp4
  5. vishalPwc commented on Jun 3, 2025

    @vishalPwc

    @ganzz4 appreciate your proposal. Can you post what could be the result in one of test case scenario mentioned below

    Steps :

    1. User have 5 workspaces with numbers 1,2,3.4,5 after a string "My Workspace"
    2. User Delete Workspace 2
    3. User Deletes Workspace 3
    4. User adds a New Work Space

    Can you provide the Expected Result as per your changes.

    Thanks in advance.

  6. ganzz4 commented on Jun 3, 2025

    @ganzz4
    Contributor

    @vishalPwc thanks for the question! Here's the expected behavior:

    Initial workspaces:

    • My Workspace
    • My Workspace 1
    • My Workspace 2
    • My Workspace 3
    • My Workspace 4
    • My Workspace 5

    The user deletes My Workspace 2 and My Workspace 3.

    Remaining:

    • My Workspace
    • My Workspace 1
    • My Workspace 4
    • My Workspace 5

    Now, the user creates a new workspace.

    According to the proposed logic (which looks for the highest number used and increments it), the new workspace will be:

    My Workspace 6

    Even though workspaces 2 and 3 were deleted, the highest number present is 5 - so the next one becomes 6.

  7. ganzz4 commented on Jun 3, 2025

    @ganzz4
    Contributor

    Here's a quick video showing the behavior in practice:

    fix.mp4
  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 4, 2025
  9. changed the title [-]Workspace - All workspaces are created with the same name as "my group workspace"[/-] [+][$250] Workspace - All workspaces are created with the same name as "my group workspace"[/+] on Jun 4, 2025
  10. melvin-bot commented on Jun 4, 2025

    @melvin-bot
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 4, 2025
  12. melvin-bot commented on Jun 4, 2025

    @melvin-bot

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

  13. 50 remaining items

  14. mallenexpensify commented on Jun 30, 2025

    @mallenexpensify
    Contributor

    All workspaces are created with the same name as "my group workspace"

    @suneox , the reason we'd want a regression test is to ensure this doesn't happen again. Are you confident that, after the fix, that a version of this can't or won't happen again? IF not, let's err on the side of adding a test. Thx

  15. suneox commented on Jul 1, 2025

    @suneox
    Contributor

    All workspaces are created with the same name as "my group workspace"

    @suneox , the reason we'd want a regression test is to ensure this doesn't happen again. Are you confident that, after the fix, that a version of this can't or won't happen again? IF not, let's err on the side of adding a test. Thx

    Agreed! I'll create a regression test to ensure this case is covered

  16. nkdengineer commented on Jul 1, 2025

    @nkdengineer
    Contributor

    @nkdengineer can you please accept the job and reply here once you have?

    @mallenexpensify Job accepted, thank you!

  17. mallenexpensify commented on Jul 3, 2025

    @mallenexpensify
    Contributor

    Contributor: @nkdengineer paid $250 via Upwork
    Contributor+: @suneox owed $250 via NewDot (awaiting onboarding)

    @suneox plz propose the regression test steps so I can get it created. Thx

  18. changed the title [-][Due for payment 2025-06-27] [$250] Workspace - All workspaces are created with the same name as "my group workspace"[/-] [+][BZ check] [$250] Workspace - All workspaces are created with the same name as "my group workspace"[/+] on Jul 3, 2025
  19. suneox commented on Jul 3, 2025

    @suneox
    Contributor

    Regression Test Proposal

    Test:

    1. Login with a new phone number
    2. In onboarding select manage team' expenses
    3. Select first option "1-10 employees" and complete the onboarding
    4. Go to Workspaces
    5. Verify the default workspace has been created with the name "My Group Workspace"
    6. Tab "Add new workspace"
    7. Verify the default workspace has been created with the name "My Group Workspace 2" then confirm
    8. Repeat steps 7-8
    9. Verify the default workspace name has been increased with pattern "My Group Workspace {n}"

    Do we agree 👍 or 👎

  20. melvin-bot commented on Jul 8, 2025

    @melvin-bot

    @mallenexpensify Huh... This is 4 days overdue. Who can take care of this?

  21. mallenexpensify commented on Jul 8, 2025

    @mallenexpensify
    Contributor
  22. suneox commented on Aug 11, 2025

    @suneox
    Contributor

    I've requested in ND

  23. JmillsExpensify commented on Aug 12, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @suneox

  24. trjExpensify commented on Aug 12, 2025

    @trjExpensify
    Contributor

    $250 approved for @suneox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions