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

[Pay when ntdiary is setup for NewDot payments][$500] Multilevel tag - Tag name in RHP is not the same as the tag being clicked on #37783

Closed
6 tasks done
kbecciv opened this issue Mar 5, 2024 · 48 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Internal Requires API changes or must be handled by Expensify staff

Comments

@kbecciv
Copy link

kbecciv commented Mar 5, 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: 1.4.47-2
Reproducible in staging?: Y
Reproducible in production?: Y
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • User is an employee of Collect workspace.
  • The Collect workspace has dependant multilevel tag set up. (details here for how to setup)
  • The multilevel tag is as follow:
    First level: State
    Second level: Region
  1. Go to workspace chat.
  2. Create a manual request with first and second level of tag.
  3. Go to request details page.
  4. Click the first level tag (State).
  5. Click the second level tag (Region).

Multi Level tag
Dependent - Multi Level tags NEW.csv

Expected Result:

When the respective level tag is opened, the RHP will show the correct tag name (Step 4 and 5).

Actual Result:

In Step 4, when opening RHP for first level tag (State), the tag name is the second level tag (Region).
In Step 5, when opening RHP for second level tag (Region), the tag name is the second level tag (State).

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6403264_1709667194180.20240305_200515.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01fff45536696176bf
  • Upwork Job ID: 1765168266617380864
  • Last Price Increase: 2024-03-10
  • Automatic offers:
    • ntdiary | Reviewer | 0
    • tienifr | Contributor | 0
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 5, 2024
Copy link

melvin-bot bot commented Mar 5, 2024

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@kbecciv
Copy link
Author

kbecciv commented Mar 5, 2024

@mallenexpensify I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

@kbecciv
Copy link
Author

kbecciv commented Mar 5, 2024

We think that this bug might be related to #wave6-collect-submitters
CC @greg-schroeder

@gijoe0295
Copy link
Contributor

gijoe0295 commented Mar 5, 2024

Proposal

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

Multilevel tag - Tag name in RHP is not the same as the tag being clicked on

What is the root cause of that problem?

In MoneyRequestView, we sort the policy tags object by orderWeight here and here, then use the indexes of that ordered array as tagIndex to identify different tags.

Later in IOURequestStepTag, we used getTagListName to retrieved the tag name based on tagIndex. The problem is getTagListName used policyTags, which is an unordered object taken straight from Onyx.

In short, we first process the policy tags object from Onyx to an array sorted based on orderWeight but later when we retrieve the tag name, we used the plain tags object from Onyx, that causes the order of tags to be messed up.

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

We should modify the getTagListName to use the sorted/processed version of policy tags:

return getTagList(policyTagList, tagIndex).name;

Note: getTagLists and getTagList are different.

What alternative solutions did you explore? (Optional)

NA

@mallenexpensify mallenexpensify added the Internal Requires API changes or must be handled by Expensify staff label Mar 6, 2024
Copy link

melvin-bot bot commented Mar 6, 2024

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

Copy link

melvin-bot bot commented Mar 6, 2024

Triggered auto assignment to Contributor Plus for review of internal employee PR - @ntdiary (Internal)

@mallenexpensify
Copy link
Contributor

mallenexpensify commented Mar 6, 2024

@ntdiary can you help me here? I just spent ~20 mins trying to get the account setup to test.

  1. On a collect plan, on expensify.com, I'm logged in as [email protected] and I invited my test account
image
  1. On staging.new.expensify.com I'm logged in with my test account
image
  1. I don't see the workspace in LHN as an option
image

Anything you know of that I'm doing wrong?

@gijoe0295
Copy link
Contributor

gijoe0295 commented Mar 6, 2024

@mallenexpensify Please take a look at QA steps 1 - 3 from #34127. Also you need to log out then log in again then the collect workspace is there. If that still didn't work, please try to create a money request to the collect workspace from employee account by the bottom bar + button.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Mar 6, 2024

Proposal

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

Multilevel tag - Tag name in RHP is not the same as the tag being clicked on

What is the root cause of that problem?

We display sorted tags by name, but we forgot to use getTagLists to sort before passing policyTagLists to getTagListName.

const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTagList), [policyTagList]);

App/src/libs/PolicyUtils.ts

Lines 179 to 188 in a04481f

function getTagLists(policyTagList: OnyxEntry<PolicyTagList>): Array<PolicyTagList[keyof PolicyTagList]> {
if (isEmptyObject(policyTagList)) {
return [];
}
return Object.values(policyTagList)
.filter((policyTagListValue) => policyTagListValue !== null)
.sort((tagA, tagB) => tagA.orderWeight - tagB.orderWeight);
}

const policyTagListName = PolicyUtils.getTagListName(policyTags, tagIndex);

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

We need to pass sorted policyTagLists to getTagListName.

    const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags), [policyTags]);
    const policyTagListName = PolicyUtils.getTagListName(policyTagLists, tagIndex);
    
    // Update getTagListName
    function getTagListName(policyTagList: PolicyTag[], tagIndex: number): string {
    if (!policyTagList.length) {
        return '';
    }
    return policyTagList[tagIndex]?.name ?? '';
}

Result

tag_list_name.mp4

@Krishna2323
Copy link
Contributor

@mallenexpensify, I think this can be external.

@ntdiary
Copy link
Contributor

ntdiary commented Mar 6, 2024

Anything you know of that I'm doing wrong?

@mallenexpensify, I guess you forgot the step 2 (i.e., executing the js code) before inviting the employee account.
After executing it, then invite the test account , I can access the test workspace. 😄

@mallenexpensify
Copy link
Contributor

I guess you forgot the step 2 (i.e., executing the js code)

Likely, thanks @ntdiary, are you able to reproduce? If so, do you think this can be external?

@ntdiary
Copy link
Contributor

ntdiary commented Mar 7, 2024

I guess you forgot the step 2 (i.e., executing the js code)

Likely, thanks @ntdiary, are you able to reproduce? If so, do you think this can be external?

@mallenexpensify, sure, I can reproduce it, and this can be fixed in NewDot, so I think this can be external. But I'm going to bed, so I can only review proposals tomorrow, if it's urgent, we can apply another c+ here. :)

@ntdiary
Copy link
Contributor

ntdiary commented Mar 8, 2024

Note: we all know that the code incorrectly uses the sorted index and the index generated by Object.keys, but when we raise a proposal, it would be better to take care of the possible impact of the modification, this logic is using the index generated by Object.keys :)

Object.keys(policyTags).forEach((policyTagKey, index) => {
const policyTagListName = PolicyUtils.getTagListName(policyTags, index) || localizedTagListName;

@mallenexpensify mallenexpensify added the External Added to denote the issue can be worked on by a contributor label Mar 10, 2024
@melvin-bot melvin-bot bot changed the title Multilevel tag - Tag name in RHP is not the same as the tag being clicked on [$500] Multilevel tag - Tag name in RHP is not the same as the tag being clicked on Mar 10, 2024
@melvin-bot melvin-bot bot added Overdue Help Wanted Apply this label when an issue is open to proposals by contributors labels Mar 10, 2024
Copy link

melvin-bot bot commented Mar 10, 2024

Current assignee @ntdiary is eligible for the External assigner, not assigning anyone new.

@mallenexpensify
Copy link
Contributor

Thx @ntdiary , added External

@melvin-bot melvin-bot bot removed the Overdue label Mar 10, 2024
@tienifr
Copy link
Contributor

tienifr commented Mar 11, 2024

Proposal

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

In Step 4, when opening RHP for first level tag (State), the tag name is the second level tag (Region).
In Step 5, when opening RHP for second level tag (Region), the tag name is the second level tag (State).

What is the root cause of that problem?

When we try to edit the tag, it will open a route with a tagIndex of 0, 1, ... This is the index of the tag in the list after sorted by orderWeight (let's call sorted index)

But when retrieving the tag name here, it's using the unsorted list to get the name, causing the switching issue in the OP.

Meanwhile, in other places like here, it's using the unsorted index to pass to getTagListName.

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

Part of the confusion here is that we're relying on index as a source of truth to pinpoint which tag we're referring to. I don't think this is a good practice because a same index can refer to different things on the same list with different ordering, like in this case.

Instead, the tag orderWeight will uniquely identify the tags in a list with any kind of ordering.

So we should (suggested in here):

  • Use the orderWeight as the id to put in the route instead of tagIndex
  • In the pages, get the orderWeight from the route
  • Pass the orderWeight down to lower components instead of propagating the "dangerous" usage of tagIndex, like here
  • Modify related methods like getTagListName to get the tag name based on orderWeight
  • Double check other usage of tagIndex and try to use orderWeight instead (where applicable)

This approach will also work fine because the orderWeight can also uniquely identify a tag, similar to the tagKey

What alternative solutions did you explore? (Optional)

  • We can sort the list in getTagListName before getting the name value (by using getTagList)
  • In here, also sort the tags before doing the forEach to make sure the index is a sorted index (it will cause regressions without this step)
  • Double check all other places that use getTagListName to make sure it passes a sorted index

@ntdiary
Copy link
Contributor

ntdiary commented Mar 12, 2024

Instead, the tag id (aka the tagKey) will uniquely identify the tags in a list with any kind of ordering.

@tienifr, Which field does tag id refer to? Is it something like these keys of Object (City/Region/State)? 😂
image

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Mar 26, 2024
@tienifr
Copy link
Contributor

tienifr commented Mar 26, 2024

@ntdiary PR #38988 is ready to review

@melvin-bot melvin-bot bot removed the Weekly KSv2 label Apr 19, 2024
Copy link

melvin-bot bot commented Apr 19, 2024

This issue has not been updated in over 15 days. @ntdiary, @NikkiWines, @mallenexpensify, @tienifr eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@melvin-bot melvin-bot bot added the Monthly KSv2 label Apr 19, 2024
@mallenexpensify
Copy link
Contributor

@mallenexpensify mallenexpensify added Weekly KSv2 and removed Monthly KSv2 labels Apr 19, 2024
@melvin-bot melvin-bot bot removed the Weekly KSv2 label May 13, 2024
Copy link

melvin-bot bot commented May 13, 2024

This issue has not been updated in over 15 days. @ntdiary, @NikkiWines, @mallenexpensify, @tienifr eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@melvin-bot melvin-bot bot added the Monthly KSv2 label May 13, 2024
@mallenexpensify mallenexpensify removed the Reviewing Has a PR in review label May 15, 2024
@mallenexpensify
Copy link
Contributor

Eeeps, that damn Reviewing label wasn't removed and this didn't have 'awaiting payment', updated title AND it didn't go overdue. grrrrr......

Contributor: @tienifr paid $500 via Upwork
Contributor+: @ntdiary owed $500 via NewDot (he's in process of getting his account dialed in)

@mallenexpensify mallenexpensify added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels May 15, 2024
@mallenexpensify mallenexpensify changed the title [$500] Multilevel tag - Tag name in RHP is not the same as the tag being clicked on [Pay when ntdiary is setup for NewDot payments][$500] Multilevel tag - Tag name in RHP is not the same as the tag being clicked on May 15, 2024
@mallenexpensify
Copy link
Contributor

@ntdiary can you update the BZ checklist plz?

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@] The PR that introduced the bug has been identified. Link to the PR:
  • [@] 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:
  • [@] A discussion in #expensify-bugs 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:
  • [@] Determine if we should create a regression test for this bug.
  • [@] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@bz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@ntdiary
Copy link
Contributor

ntdiary commented May 15, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

Regression test:

Precondition:

  1. User is an employee of Collect workspace.
  2. The Collect workspace has dependant multilevel tag set up. (e.g., State/Region)

Steps:

  1. Go to workspace chat.
  2. Create a manual request with first and second level of tag.
  3. Go to request details page.
  4. Click the first level tag (State), verify the title of the RHP header is State.
  5. Click the second level tag (Region), verify the title of the RHP header is Region.

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels May 21, 2024
@mallenexpensify
Copy link
Contributor

mallenexpensify commented May 24, 2024

From above

Contributor+: @ntdiary owed $500 via NewDot (he's in process of getting his account dialed in)

@ntdiary should be setup for NewDot payment now or very, very soon, so I'm going to close this and they can request payment once they're dialed in.

TestRail GH is here

@JmillsExpensify
Copy link

$500 approved for @ntdiary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Internal Requires API changes or must be handled by Expensify staff
Projects
No open projects
Archived in project
Development

No branches or pull requests

9 participants