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

[$250] Workspace - The new WS names appear in English when Spanish is set up #53599

Open
4 of 8 tasks
vincdargento opened this issue Dec 4, 2024 · 44 comments
Open
4 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@vincdargento
Copy link

vincdargento commented Dec 4, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: v9.0.71-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5298436
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Open the app or go to: https://staging.expensify.com/
  2. Loggin
  3. Click on 'Settings' > 'Preferences' > 'Language' > 'Spanish'
  4. Click on 'Espacios de trabajo' > 'Nuevo espacio de trabajo'

Expected Result:

When a new WS is created, the name should be in Spanish.

Actual Result:

When a new WS is created, the name is in English.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021867717521858784433
  • Upwork Job ID: 1867717521858784433
  • Last Price Increase: 2025-01-17
  • Automatic offers:
    • Krishna2323 | Contributor | 105797605
Issue OwnerCurrent Issue Owner: @eVoloshchak
@vincdargento vincdargento added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

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

@Krishna2323
Copy link
Contributor

Krishna2323 commented Dec 4, 2024

Edited by proposal-police: This proposal was edited at 2024-12-05 01:16:03 UTC.

Proposal

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

Workspace - The new WS names appear in English when Spanish is set up

What is the root cause of that problem?

  • We are directly returning the new workspace name string in english.

function generateDefaultWorkspaceName(email = ''): string {
const emailParts = email ? email.split('@') : sessionEmail.split('@');
let defaultWorkspaceName = '';
if (!emailParts || emailParts.length !== 2) {
return defaultWorkspaceName;
}
const username = emailParts.at(0) ?? '';
const domain = emailParts.at(1) ?? '';
const userDetails = PersonalDetailsUtils.getPersonalDetailByEmail(sessionEmail);
const displayName = userDetails?.displayName?.trim();
if (!PUBLIC_DOMAINS.some((publicDomain) => publicDomain === domain.toLowerCase())) {
defaultWorkspaceName = `${Str.UCFirst(domain.split('.').at(0) ?? '')}'s Workspace`;
} else if (displayName) {
defaultWorkspaceName = `${Str.UCFirst(displayName)}'s Workspace`;
} else if (PUBLIC_DOMAINS.some((publicDomain) => publicDomain === domain.toLowerCase())) {
defaultWorkspaceName = `${Str.UCFirst(username)}'s Workspace`;
} else {
defaultWorkspaceName = userDetails?.phoneNumber ?? '';
}
if (`@${domain.toLowerCase()}` === CONST.SMS.DOMAIN) {
defaultWorkspaceName = 'My Group Workspace';
}
if (isEmptyObject(allPolicies)) {
return defaultWorkspaceName;
}
// find default named workspaces and increment the last number
const numberRegEx = new RegExp(`${escapeRegExp(defaultWorkspaceName)} ?(\\d*)`, 'i');
const parsedWorkspaceNumbers = Object.values(allPolicies ?? {})
.filter((policy) => policy?.name && numberRegEx.test(policy.name))
.map((policy) => Number(numberRegEx.exec(policy?.name ?? '')?.[1] ?? '1')); // parse the number at the end
const lastWorkspaceNumber = Math.max(...parsedWorkspaceNumbers);
return lastWorkspaceNumber !== -Infinity ? `${defaultWorkspaceName} ${lastWorkspaceNumber + 1}` : defaultWorkspaceName;
}

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

  • We should create a translation in both languages which will receive the user name and return the workspace name accordingly. We would also need to update the regex a bit to get the last workspace number in both languages. The regex can be modified in the PR phase if needed. We might want to include username in the numberRegEx.
  • We also need to create translation for My Group Workspace.
EN: workspaceName: (userName: string, workspaceNumber?: number) => `${userName}'s Workspace${workspaceNumber ? ' ' + workspaceNumber : ''}`,
ES: workspaceName: (userName: string, workspaceNumber?: number) => `El espacio de trabajo${workspaceNumber ? ' ' + workspaceNumber : ''} de ${userName}`,

EN: myGroupWorkspace: 'My Group Workspace',
ES: myGroupWorkspace:"Mi Espacio de Trabajo en Grupo"
Pseudocode
/**
 * Generate a policy name based on an email and policy list.
 * @param [email] the email to base the workspace name on. If not passed, will use the logged-in user's email instead
 */
function generateDefaultWorkspaceName(email = ''): string {
    const emailParts = email ? email.split('@') : sessionEmail.split('@');
    if (!emailParts || emailParts.length !== 2) {
        return '';
    }

    const username = emailParts.at(0) ?? '';
    const domain = emailParts.at(1)?.toLowerCase() ?? '';
    const userDetails = PersonalDetailsUtils.getPersonalDetailByEmail(sessionEmail);
    const displayName = userDetails?.displayName?.trim();
    let displayNameForWorkspace = '';

    if (!PUBLIC_DOMAINS.some((publicDomain) => publicDomain === domain)) {
        displayNameForWorkspace = Str.UCFirst(domain.split('.').at(0) ?? '');
    } else if (displayName) {
        displayNameForWorkspace = Str.UCFirst(displayName);
    } else if (PUBLIC_DOMAINS.some((publicDomain) => publicDomain === domain)) {
        displayNameForWorkspace = Str.UCFirst(username);
    } else {
        displayNameForWorkspace = userDetails?.phoneNumber ?? '';
    }

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

    if (isEmptyObject(allPolicies)) {
        return Localize.translateLocal('workspace.new.workspaceName', displayNameForWorkspace);
    }

    // Dynamically include the username in the regex
    const escapedName = displayNameForWorkspace.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    const englishRegex = new RegExp(`${escapedName}'s Workspace(?:\\s(\\d+))?$`, 'i');
    const spanishRegex = new RegExp(`El espacio de trabajo(?:\\s(\\d+))? de ${escapedName}$`, 'i');

    const workspaceNumbers = Object.values(allPolicies)
        .map((policy) => englishRegex.exec(policy?.name ?? '') || spanishRegex.exec(policy?.name ?? ''))
        .filter(Boolean) // Remove null matches
        .map((match) => Number(match?.[1] ?? '1'));

    const lastWorkspaceNumber = workspaceNumbers.length > 0 ? Math.max(...workspaceNumbers) : -Infinity;

    return lastWorkspaceNumber !== -Infinity
        ? Localize.translateLocal('workspace.new.workspaceName', displayNameForWorkspace, lastWorkspaceNumber + 1)
        : Localize.translateLocal('workspace.new.workspaceName', displayNameForWorkspace);
}ceNumber) : defaultWorkspaceName;
}

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


What alternative solutions did you explore? (Optional)

Result

Monosnap.screencast.2024-12-19.11-20-42.mp4

@stephanieelliott
Copy link
Contributor

I think this is expected behavior, once a workspace is named it should remain static unless manually edited. I don't think changing the language should update the naming for existing workspaces. I am gonna close this as I don't think we should do anything here.

@vincdargento
Copy link
Author

@stephanieelliott Actually the issue is happening with new workspaces. When the language is set up as Spanish, new workspaces have the name in English, tester can still reproduce. Opening in case you change your mind with this knowledge

macOS.Sequoia.15.1.1._.Chrome.mp4

@stephanieelliott
Copy link
Contributor

Thanks @vincdargento! There is a similar issue being worked on here, asking to see if we're addressing WS names there or if we will need a separate PR

@stephanieelliott
Copy link
Contributor

Ok seems like this is a unique issue, adding labels so we can get this fixed.

@melvin-bot melvin-bot bot removed the Overdue label Dec 13, 2024
@stephanieelliott stephanieelliott added External Added to denote the issue can be worked on by a contributor Overdue labels Dec 13, 2024
@melvin-bot melvin-bot bot changed the title Workspace - The new WS names appear in English when Spanish is set up [$250] Workspace - The new WS names appear in English when Spanish is set up Dec 13, 2024
Copy link

melvin-bot bot commented Dec 13, 2024

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

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

melvin-bot bot commented Dec 13, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Dec 13, 2024
@shubham1206agra
Copy link
Contributor

Proposal

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

Workspace - The new WS names appear in English when Spanish is set up

What is the root cause of that problem?

The function generateDefaultWorkspaceName does not support localized language. That's why all new workspace are in English only.

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

Modify the function generateDefaultWorkspaceName to add the localized translated names using Localize.translateLocal.

Copies will be provided later by Internal team

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

Add tests for generateDefaultWorkspaceName to test different scenarios.

What alternative solutions did you explore? (Optional)

NA

@eVoloshchak
Copy link
Contributor

@Krishna2323's proposal is looking good!

🎀👀🎀 C+ reviewed!

Copy link

melvin-bot bot commented Dec 16, 2024

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

@shubham1206agra
Copy link
Contributor

@eVoloshchak @MonilBhavsar I don't think the choice is correct here since the selected proposal did not fill the tests section, i.e., the proposal is incomplete.

See https://expensify.slack.com/archives/C01GTK53T8Q/p1733148961659549

@garrettmknight garrettmknight moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Dec 17, 2024
Copy link

melvin-bot bot commented Dec 18, 2024

@eVoloshchak @stephanieelliott @MonilBhavsar this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Dec 30, 2024

@eVoloshchak, @stephanieelliott, @MonilBhavsar 12 days overdue now... This issue's end is nigh!

Copy link

melvin-bot bot commented Jan 1, 2025

@eVoloshchak @stephanieelliott @MonilBhavsar this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

@melvin-bot melvin-bot bot removed the Daily KSv2 label Jan 2, 2025
Copy link

melvin-bot bot commented Jan 2, 2025

This issue has not been updated in over 14 days. @eVoloshchak, @stephanieelliott, @MonilBhavsar eroding to Weekly issue.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Overdue labels Jan 2, 2025
Copy link

melvin-bot bot commented Jan 3, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@stephanieelliott
Copy link
Contributor

Bump on this @eVoloshchak, can you please weigh in on the above?

@stephanieelliott
Copy link
Contributor

Hey @eVoloshchak waiting for your input here 🙏

@stephanieelliott
Copy link
Contributor

@eVoloshchak
Copy link
Contributor

I still think @Krishna2323's proposal is valid.
The issue is very straightforward, the unit test for this is obvious, if we're changing translations - we just need to check that the right text is used

Add tests for generateDefaultWorkspaceName to test different scenarios.

I don't think that's enough of a differentiator to change the proposal we're implementing

However, @shubham1206agra is technically right. @Krishna2323's proposal is technically invalid, unit tests section isn't listed as "optional".
I don't know what the rules are in this case, and how we should proceed. What would be considered fair?

Copy link

melvin-bot bot commented Jan 10, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@Krishna2323
Copy link
Contributor

@MonilBhavsar, please this comment when you get a chance. Thanks!

Copy link

melvin-bot bot commented Jan 17, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@stephanieelliott
Copy link
Contributor

Hey @MonilBhavsar, bump on this comment please.

My .02 -- I think we’re getting hung up on semantics here. If @eVoloshchak believes that @Krishna2323's proposal is the best path forward, then I suggest we proceed with that and focus on moving this issue forward.

Regarding the Slack post, it does not explicitly state that tests are a firm requirement. Instead, it suggests tests but leaves the decision to the developer’s judgment on whether or not they are appropriate for that specific proposal. If tests are needed, let's add them -- it doesn't make sense to nullify the whole proposal over it

@MonilBhavsar
Copy link
Contributor

Agree with these comments - #53599 (comment) #53599 (comment)

@melvin-bot melvin-bot bot added the Overdue label Jan 21, 2025
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 21, 2025
Copy link

melvin-bot bot commented Jan 21, 2025

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

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot removed the Overdue label Jan 21, 2025
@stephanieelliott
Copy link
Contributor

Hey @Krishna2323 can you give an ETA for when you will have a PR up?

@Krishna2323
Copy link
Contributor

@stephanieelliott, sorry for the delay. I'm on leave until today and will start working on the PR from tomorrow. I thought I had left a comment about my leave—sorry for that again.

@Krishna2323
Copy link
Contributor

@eVoloshchak, the PR is ready for review.

@stephanieelliott
Copy link
Contributor

Bump on this @eVoloshchak -- PR is waiting for your review

@stephanieelliott
Copy link
Contributor

PR is under review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

6 participants