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 #55436][$250] Wrong system message when updating role in Spanish #55781

Open
1 of 8 tasks
m-natarajan opened this issue Jan 27, 2025 · 16 comments
Open
1 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Jan 27, 2025

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: 9.0.89-5
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @dukenv0307
Slack conversation (hyperlinked to channel name): expensify_bugs

Action Performed:

  1. Invite a new user to a workspace
  2. Update role of this user to admin
  3. Update role of this user to auditor
  4. Go to #admin room

Expected Result:

System message of update role show correct

Actual Result:

System message of update role shows wrong

Workaround:

Unknown

Platforms:

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

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

Screenshots/Videos

Add any screenshot/video evidence
bug-resize.mp4

Image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021884096456183632431
  • Upwork Job ID: 1884096456183632431
  • Last Price Increase: 2025-01-28
  • Automatic offers:
    • shubham1206agra | Contributor | 105909090
Issue OwnerCurrent Issue Owner: @rojiphil
@m-natarajan m-natarajan added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Jan 27, 2025
Copy link

melvin-bot bot commented Jan 27, 2025

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

@m-natarajan
Copy link
Author

Propopsal from @shubham1206agra

Proposal

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

Wrong system message when updating role in Spanish

What is the root cause of that problem?

In

App/src/languages/es.ts

Lines 4970 to 4975 in b59f23b

addEmployee: ({email, role}: AddEmployeeParams) => `agregó a ${email} como ${role === 'miembro' || role === 'user' ? 'miembro' : 'administrador'}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
`actualicé el rol ${email} de ${currentRole === 'miembro' || currentRole === 'user' ? 'miembro' : 'administrador'} a ${
newRole === 'miembro' || newRole === 'user' ? 'miembro' : 'administrador'
}`,
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'miembro' || role === 'user' ? 'miembro' : 'administrador'} ${email}`,

We do not cover the case of auditor role of the workspace user. That causes the wrong translation to occur.

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

Let's simplify these translations

Change

App/src/languages/es.ts

Lines 4970 to 4975 in b59f23b

addEmployee: ({email, role}: AddEmployeeParams) => `agregó a ${email} como ${role === 'miembro' || role === 'user' ? 'miembro' : 'administrador'}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
`actualicé el rol ${email} de ${currentRole === 'miembro' || currentRole === 'user' ? 'miembro' : 'administrador'} a ${
newRole === 'miembro' || newRole === 'user' ? 'miembro' : 'administrador'
}`,
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'miembro' || role === 'user' ? 'miembro' : 'administrador'} ${email}`,

to

addEmployee: ({email, role}: AddEmployeeParams) => `agregó a ${email} como ${role}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `actualicé el rol ${email} de ${currentRole} a ${newRole}`,
removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role} ${email}`,

Now, let's update the reference of these (utilizing translation of workspace.common.roleName)

Change

const newRole = originalMessage?.newValue ?? '';
const oldRole = originalMessage?.oldValue ?? '';
return translateLocal('report.actions.type.updateRole', {email, newRole, currentRole: oldRole});

to

const newRole = translateLocal('workspace.common.roleName', {role: originalMessage?.newValue ?? ''}).toLowerCase(); 
const oldRole = translateLocal('workspace.common.roleName', {role: originalMessage?.oldValue ?? ''}).toLowerCase(); 
return translateLocal('report.actions.type.updateRole', {email, newRole, currentRole: oldRole}); 

Change

const role = originalMessage?.role ?? '';
const formattedEmail = formatPhoneNumber(email);
return translateLocal('report.actions.type.addEmployee', {email: formattedEmail, role});

to

const role = translateLocal('workspace.common.roleName', {role: originalMessage?.role ?? ''}).toLowerCase();
const formattedEmail = formatPhoneNumber(email);
return translateLocal('report.actions.type.addEmployee', {email: formattedEmail, role});

And change

const role = originalMessage?.role ?? '';
return translateLocal('report.actions.type.removeMember', {email, role});

to

const role = translateLocal('workspace.common.roleName', {role: originalMessage?.role ?? ''}).toLowerCase();
return translateLocal('report.actions.type.removeMember', {email, role});

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

NA since this is a simple translation change

What alternative solutions did you explore? (Optional)

@daledah
Copy link
Contributor

daledah commented Jan 27, 2025

Proposal

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

Wrong system message when updating role in Spanish

What is the root cause of that problem?

App/src/languages/es.ts

Lines 4971 to 4974 in b59f23b

updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
`actualicé el rol ${email} de ${currentRole === 'miembro' || currentRole === 'user' ? 'miembro' : 'administrador'} a ${
newRole === 'miembro' || newRole === 'user' ? 'miembro' : 'administrador'
}`,

In the condition above we are using 'auditor' instead of 'user' because the role can only be user, auditor, admin

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

We should update all 'miembro' in the condition to 'auditor'

App/src/languages/es.ts

Lines 4971 to 4974 in b59f23b

updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
`actualicé el rol ${email} de ${currentRole === 'miembro' || currentRole === 'user' ? 'miembro' : 'administrador'} a ${
newRole === 'miembro' || newRole === 'user' ? 'miembro' : 'administrador'
}`,

We should do the same way with addEmployee, removeMember

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

None

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.

@MitchExpensify MitchExpensify added the External Added to denote the issue can be worked on by a contributor label Jan 28, 2025
@melvin-bot melvin-bot bot changed the title Wrong system message when updating role in Spanish [$250] Wrong system message when updating role in Spanish Jan 28, 2025
Copy link

melvin-bot bot commented Jan 28, 2025

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

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

melvin-bot bot commented Jan 28, 2025

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

@MitchExpensify MitchExpensify moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Jan 28, 2025
@dangrous dangrous self-assigned this Jan 28, 2025
@dangrous
Copy link
Contributor

I can take a look at this once it's ready for an internal engineer!

@rojiphil
Copy link
Contributor

Will pick this up for proposal review today

@rojiphil
Copy link
Contributor

Thanks for the proposals

@daledah Replacing 'miembro' with 'auditor' may work but it is better to do a clean up as suggested in @shubham1206agra proposal.

@shubham1206agra I like the idea of simplifying the translations using the translation of workspace.common.roleName. Also, note that workspace.common.roleName would return member instead of the currently used user. We would have to confirm if this change is fine.
Otherwise @shubham1206agra proposal LGTM.
🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 29, 2025

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

@shubham1206agra
Copy link
Contributor

Thanks for the proposals

@daledah Replacing 'miembro' with 'auditor' may work but it is better to do a clean up as suggested in @shubham1206agra proposal.

@shubham1206agra I like the idea of simplifying the translations using the translation of workspace.common.roleName. Also, note that workspace.common.roleName would return member instead of the currently used user. We would have to confirm if this change is fine. Otherwise @shubham1206agra proposal LGTM. 🎀👀🎀 C+ reviewed

@rojiphil We can modify this if we found some edge case in the PR itself.

Copy link

melvin-bot bot commented Jan 29, 2025

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

@dangrous
Copy link
Contributor

Hi! This looks good, I think member instead of user is fine but I can double check internally.

However, can we be sure to add some unit tests for the new behavior (translated) of getPolicyChangeLogChangeRoleMessage and the other utils we're changing? Thanks!

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

melvin-bot bot commented Jan 29, 2025

📣 @shubham1206agra 🎉 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 📖

@dangrous
Copy link
Contributor

yep "member" is expected!

@dangrous
Copy link
Contributor

Hi again! I think we might want to hold our PR on #55596, which will change that logic slightly. Should be essentially the same solution, though.

@dangrous dangrous changed the title [$250] Wrong system message when updating role in Spanish [HOLD #55436][$250] Wrong system message when updating role in Spanish Jan 31, 2025
@dangrous
Copy link
Contributor

Updated title to hold on that other issue.

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

6 participants