[HOLD for payment 2024-12-07] [$250] Tag rules - Approver field in tag editor shows user email instead of user name
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.63-3 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team
Action Performed:
- Go to staging.new.expensify.com
- Go to workspace settings > Workflows.
- Click on the existing approval workflow under Add approvals.
- Note that Approver field shows user name.
- Go to workspace settings > Tags.
- Click on any tag.
- Click Approver.
- Select a user with custom name.
Expected Result:
Approver field in tag editor will show user name.
Actual Result:
Approver field in tag editor shows user email instead of user name.
In Category editor, Approver field shows user name.
Workaround:
Unknown
Platforms:
- [x] Android: Standalone
- [x] Android: HybridApp
- [x] Android: mWeb Chrome
- [x] iOS: Standalone
- [ ] iOS: HybridApp
- [x] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [x] MacOS: Desktop
Screenshots/Videos
https://github.com/user-attachments/assets/36707c93-fe19-4452-a0ec-e8eec0b54c9d
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021858313853614949592
- Upwork Job ID: 1858313853614949592
- Last Price Increase: 2024-11-18
- Automatic offers:
- etCoderDysto | Contributor | 104985198
Issue Owner
Current Issue Owner: @kadiealexander
Triggered auto assignment to @kadiealexander (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.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Approver field in tag editor shows user email instead of user name
What is the root cause of that problem?
We are getting the approvers email address here https://github.com/Expensify/App/blob/9774032c7b9e72c5f8ee0de6adbe843a7efa2c4a/src/pages/workspace/tags/TagSettingsPage.tsx#L107 And we are displying the email address
What changes do you think we should make in order to solve the problem?
We should get user's display name using PersonalDetailsUtils.getPersonalDetailByEmail(tagApprover)?.displayName;
And display the user display name when it is available and fallback to displaying the user email when display name is not available
Code implementation
const tagApprover = PolicyUtils.getTagApproverRule(policyID, route.params.tagName)?.approver ?? '';
const approver = PersonalDetailsUtils.getPersonalDetailByEmail(tagApprover)?.displayName;
Note: we can use useMemo to optimize recalculating displayName as we do on categories page
What alternative solutions did you explore? (Optional)
Edited by proposal-police: This proposal was edited at 2024-11-18 04:57:50 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Tag rules - Approver field in tag editor shows user email instead of user name
What is the root cause of that problem?
We display this display name --> email in CategorySettingsPage
https://github.com/Expensify/App/blob/9774032c7b9e72c5f8ee0de6adbe843a7efa2c4a/src/pages/workspace/categories/CategorySettingsPage.tsx#L79-L83
But we only display the text returns from getTagApproverRule function which is the user email
https://github.com/Expensify/App/blob/9774032c7b9e72c5f8ee0de6adbe843a7efa2c4a/src/pages/workspace/tags/TagSettingsPage.tsx#L107
https://github.com/Expensify/App/blob/9774032c7b9e72c5f8ee0de6adbe843a7efa2c4a/src/pages/workspace/tags/TagSettingsPage.tsx#L183
What changes do you think we should make in order to solve the problem?
In TagSettingsPage, we should do the same way here to display the tag approver display name first.
I notice that we need to use
||becauseapproverDetails?.displayNamecan be an empty string if the user doesn't have a custom display name. And we need to fix the same inCategorySettingsPage
const tagApprover = useMemo(() => {
const tagApproverEmail = PolicyUtils.getTagApproverRule(policyID, route.params.tagName)?.approver ?? '';
const approverDetails = getPersonalDetailByEmail(tagApproverEmail);
return approverDetails?.displayName || tagApproverEmail;
}, [policyID, route.params.tagName]);
https://github.com/Expensify/App/blob/9774032c7b9e72c5f8ee0de6adbe843a7efa2c4a/src/pages/workspace/tags/TagSettingsPage.tsx#L107
https://github.com/Expensify/App/blob/9774032c7b9e72c5f8ee0de6adbe843a7efa2c4a/src/pages/workspace/tags/TagSettingsPage.tsx#L183
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.
Job added to Upwork: https://www.upwork.com/jobs/~021858313853614949592
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 (External)
Thank you for your speedy proposals!
This issue is straightforward and @etCoderDysto 's proposal was first, so let's go with their proposal!
πππ C+ reviewed
Triggered auto assignment to @mountiny, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@eh2077 Could you please check again
- This implementation isn't correct, it doesn't fallback to the approver email if the display name is empty or undefined
const approver = PersonalDetailsUtils.getPersonalDetailByEmail(tagApprover)?.displayName;
I notice that we need to use || because approverDetails?.displayName can be an empty string if the user doesn't have a custom display name. And we need to fix the same in CategorySettingsPage
- If we use the same way with
CategorySettingsPage, we need to use||instead of??becausedisplayNamecan be an empty string.
@mkzie2 Thanks for your comment. I voted for @etCoderDysto 's proposal because I think the initial version of their proposal is clear to fix this straightforward issue.
If we use the same way with CategorySettingsPage, we need to use || instead of ?? because displayName can be an empty string.
I appreciated your discussion on this though I believe this won't be an issue for most use cases because we're not allowed to save empty display name.
I appreciated your discussion on this though I believe this won't be an issue for most use cases because we're not allowed to save empty display name.
The user can skip the onboarding if it's a new account that is invited to a WS or an existing user creates an expense with this user before the new user login the first time.
The user can skip the onboarding if it's a new account that is invited to a WS or an existing user creates an expense with this user before the new user login the first time.
- Only
firstName, andlastNamecan be empty string in the above scenario,displayNameresorts to user email when the user doesn't havefirstNameandlastName
- And approver field will filled will display user's email if we follow the same pattern as CategorySettingsPage
π£ @etCoderDysto π 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 π
Reviewing label has been removed, please complete the "BugZero Checklist".
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.68-7 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/52961
If no regressions arise, payment will be issued on 2024-12-07. :confetti_ball:
For reference, here are some details about the assignees on this issue:
- @eh2077 requires payment through NewDot Manual Requests
- @etCoderDysto requires payment automatic offer (Contributor)
@eh2077 @kadiealexander @eh2077 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
Payments due:
- [x] Contributor: @etCoderDysto paid $250 via Upwork (automatic offer)
- [x] Reviewer: @eh2077 owed $250 via manual request
@eh2077 please don't forget the checklist!
BugZero Checklist:
- [x] [Contributor] Classify the bug:
Bug classification
Source of bug:
- [ ] 1a. Result of the original design (eg. a case wasn't considered)
- [x] 1b. Mistake during implementation
- [ ] 1c. Backend bug
- [ ] 1z. Other:
Where bug was reported:
- [x] 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
- [x] 2b. Reported on staging (eg. found during regression or PR testing)
- [ ] 2d. Reported on a PR
- [ ] 2z. Other:
Who reported the bug:
- [ ] 3a. Expensify user
- [ ] 3b. Expensify employee
- [ ] 3c. Contributor
- [x] 3d. QA
- [ ] 3z. Other:
-
[x] [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: https://github.com/Expensify/App/pull/48325/files#r1880057860
-
[x] [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
-
[x] [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.
I don't think we need to add a new regression test because
- The fix is a minor and straightforward improvement about approver name display
- It doesn't impact user flow
-
[ ] [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Do we agree π or π
Requested payment in NewDot
$250 approved for @eh2077