App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2024-12-07] [$250] Tag rules - Approver field in tag editor shows user email instead of user name

Open IuliiaHerets opened this issue 1 year ago β€’ 17 comments

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:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Workflows.
  3. Click on the existing approval workflow under Add approvals.
  4. Note that Approver field shows user name.
  5. Go to workspace settings > Tags.
  6. Click on any tag.
  7. Click Approver.
  8. 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

View all open jobs on GitHub

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 OwnerCurrent Issue Owner: @kadiealexander

IuliiaHerets avatar Nov 17 '24 18:11 IuliiaHerets

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.

melvin-bot[bot] avatar Nov 17 '24 18:11 melvin-bot[bot]

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)

etCoderDysto avatar Nov 17 '24 18:11 etCoderDysto

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 || 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

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.

mkzie2 avatar Nov 17 '24 18:11 mkzie2

Proposal updated:

Added code implementation details

etCoderDysto avatar Nov 17 '24 18:11 etCoderDysto

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

melvin-bot[bot] avatar Nov 18 '24 00:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 18 '24 00:11 melvin-bot[bot]

Updated proposal.

  • Add an edge case.

mkzie2 avatar Nov 18 '24 04:11 mkzie2

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

eh2077 avatar Nov 19 '24 15:11 eh2077

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

melvin-bot[bot] avatar Nov 19 '24 15:11 melvin-bot[bot]

@eh2077 Could you please check again

  1. 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

  1. If we use the same way with CategorySettingsPage, we need to use || instead of ?? because displayName can be an empty string.

mkzie2 avatar Nov 19 '24 15:11 mkzie2

@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.

eh2077 avatar Nov 19 '24 16:11 eh2077

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.

mkzie2 avatar Nov 19 '24 16:11 mkzie2

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, and lastName can be empty string in the above scenario, displayName resorts to user email when the user doesn't have firstName and lastName
Screenshot 2024-11-19 at 8 00 07 in the evening
  • And approver field will filled will display user's email if we follow the same pattern as CategorySettingsPage
Screenshot 2024-11-19 at 8 03 22 in the evening

etCoderDysto avatar Nov 19 '24 17:11 etCoderDysto

πŸ“£ @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 πŸ“–

melvin-bot[bot] avatar Nov 20 '24 10:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 30 '24 13:11 melvin-bot[bot]

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)

melvin-bot[bot] avatar Nov 30 '24 13:11 melvin-bot[bot]

@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]

melvin-bot[bot] avatar Nov 30 '24 13:11 melvin-bot[bot]

Payments due:

  • [x] Contributor: @etCoderDysto paid $250 via Upwork (automatic offer)
  • [x] Reviewer: @eh2077 owed $250 via manual request

kadiealexander avatar Dec 09 '24 02:12 kadiealexander

@eh2077 please don't forget the checklist!

kadiealexander avatar Dec 09 '24 02:12 kadiealexander

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

  1. The fix is a minor and straightforward improvement about approver name display
  2. 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 πŸ‘Ž

eh2077 avatar Dec 11 '24 11:12 eh2077

Requested payment in NewDot

eh2077 avatar Dec 11 '24 12:12 eh2077

$250 approved for @eh2077

JmillsExpensify avatar Dec 11 '24 16:12 JmillsExpensify