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 for payment 2024-03-14] [MEDIUM] Ensure that we preserve order of tags for multiple levels of tag lists #37054

Closed
yuwenmemon opened this issue Feb 21, 2024 · 11 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

Comments

@yuwenmemon
Copy link
Contributor

yuwenmemon commented Feb 21, 2024

Context

We just recently merged #34983, which adds support for multiple levels of tags in the App.

Problem

However, one consideration we missed with the above project was that tags can be reordered, and that this order does not get preserved by the API when sending tags over as a JSON Object. In other words, the following tag list in our database:

Tags in DB Form
    "tagLists":
    [
        {
            "tagListData":
            {
                "name": "Project",
                "tags":
                [
                    {
                        "name": "Project 1",
                        "GL Code": "10",
                        "enabled": true
                    },
                    {
                        "name": "Project 2",
                        "GL Code": "20",
                        "enabled": true
                    },
                    {
                        "name": "Project 3",
                        "GL Code": "30",
                        "enabled": true
                    },
                    {
                        "name": "Project 4",
                        "GL Code": "40",
                        "enabled": true
                    },
                    {
                        "name": "Project 5",
                        "GL Code": "50",
                        "enabled": true
                    },
                    {
                        "name": "Project 6",
                        "GL Code": "60",
                        "enabled": true
                    }
                ],
                "required": true
            }
        },
        {
            "tagListData":
            {
                "name": "Region",
                "tags":
                [
                    {
                        "name": "Africa",
                        "GL Code": "300",
                        "enabled": true
                    },
                    {
                        "name": "Asia",
                        "GL Code": "500",
                        "enabled": true
                    },
                    {
                        "name": "Australia",
                        "GL Code": "600",
                        "enabled": true
                    },
                    {
                        "name": "Europe",
                        "GL Code": "400",
                        "enabled": true
                    },
                    {
                        "name": "North America",
                        "GL Code": "100",
                        "enabled": true
                    },
                    {
                        "name": "South America",
                        "GL Code": "200",
                        "enabled": true
                    }
                ],
                "required": true
            }
        },
        {
            "tagListData":
            {
                "name": "Department",
                "tags":
                [
                    {
                        "name": "Accounting",
                        "GL Code": "1000",
                        "enabled": true
                    },
                    {
                        "name": "Engineering",
                        "GL Code": "5000",
                        "enabled": true
                    },
                    {
                        "name": "HR",
                        "GL Code": "4000",
                        "enabled": true
                    },
                    {
                        "name": "Marketing",
                        "GL Code": "2000",
                        "enabled": true
                    },
                    {
                        "name": "Ops",
                        "GL Code": "6000",
                        "enabled": true
                    },
                    {
                        "name": "Sales",
                        "GL Code": "3000",
                        "enabled": true
                    }
                ],
                "required": true
            }
        }
    ],

Would get translated to the following in Onyx, where the order is alphabetical for the keys:

Tags in Onyx Form
  {
      "key": "policyTags_D2B2C46682504F5A",
      "onyxMethod": "set",
      "value": {
          "Department": {
              "name": "Department",
              "required": true,
              "tags": {
                  "Accounting": {
                      "GL Code": "1000",
                      "enabled": true,
                      "name": "Accounting"
                  },
                  "Engineering": {
                      "GL Code": "5000",
                      "enabled": true,
                      "name": "Engineering"
                  },
                  "HR": {
                      "GL Code": "4000",
                      "enabled": true,
                      "name": "HR"
                  },
                  "Marketing": {
                      "GL Code": "2000",
                      "enabled": true,
                      "name": "Marketing"
                  },
                  "Ops": {
                      "GL Code": "6000",
                      "enabled": true,
                      "name": "Ops"
                  },
                  "Sales": {
                      "GL Code": "3000",
                      "enabled": true,
                      "name": "Sales"
                  }
              }
          },
          "Project": {
              "name": "Project",
              "required": true,
              "tags": {
                  "Project 1": {
                      "GL Code": "10",
                      "enabled": true,
                      "name": "Project 1"
                  },
                  "Project 2": {
                      "GL Code": "20",
                      "enabled": true,
                      "name": "Project 2"
                  },
                  "Project 3": {
                      "GL Code": "30",
                      "enabled": true,
                      "name": "Project 3"
                  },
                  "Project 4": {
                      "GL Code": "40",
                      "enabled": true,
                      "name": "Project 4"
                  },
                  "Project 5": {
                      "GL Code": "50",
                      "enabled": true,
                      "name": "Project 5"
                  },
                  "Project 6": {
                      "GL Code": "60",
                      "enabled": true,
                      "name": "Project 6"
                  }
              }
          },
          "Region": {
              "name": "Region",
              "required": true,
              "tags": {
                  "Africa": {
                      "GL Code": "300",
                      "enabled": true,
                      "name": "Africa"
                  },
                  "Asia": {
                      "GL Code": "500",
                      "enabled": true,
                      "name": "Asia"
                  },
                  "Australia": {
                      "GL Code": "600",
                      "enabled": true,
                      "name": "Australia"
                  },
                  "Europe": {
                      "GL Code": "400",
                      "enabled": true,
                      "name": "Europe"
                  },
                  "North America": {
                      "GL Code": "100",
                      "enabled": true,
                      "name": "North America"
                  },
                  "South America": {
                      "GL Code": "200",
                      "enabled": true,
                      "name": "South America"
                  }
              }
          }
      }
  },

This causes the wrong tag level to be pulled from the code in NewDot that accesses tags by "index"

Solution

As discussed here (internal slack link), start sending an orderWeight with the JSON Object of tags sent to the App. This will be generated on the fly. Then use that orderWeight to retrieve the proper tag level in getTagList

cc @flodnv @iwiznia @cead22 @rezkiy37 @amyevans @puneetlath

@yuwenmemon yuwenmemon added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Feb 21, 2024
@yuwenmemon yuwenmemon self-assigned this Feb 21, 2024
Copy link

melvin-bot bot commented Feb 21, 2024

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

@yuwenmemon yuwenmemon changed the title Ensure that Ensure that we preserve order of tags for multiple levels of tag lists Feb 21, 2024
@greg-schroeder greg-schroeder changed the title Ensure that we preserve order of tags for multiple levels of tag lists [MEDIUM] Ensure that we preserve order of tags for multiple levels of tag lists Feb 21, 2024
@flodnv
Copy link
Contributor

flodnv commented Feb 22, 2024

@melvin-bot melvin-bot bot added the Overdue label Feb 26, 2024
@CortneyOfstad
Copy link
Contributor

@yuwenmemon so I tried reading through the linked comment above from @flodnv, and I am going to be honest — I have not a clue where we're at or what the next steps are. Do you have an update on where we're at with this so I can proceed from a BugZero perspective? Thanks!

@flodnv
Copy link
Contributor

flodnv commented Feb 26, 2024

Unassigning @CortneyOfstad, we don't need BugZero here 😕

After discussing, I agree with the proposed solution

@CortneyOfstad
Copy link
Contributor

Thanks @flodnv! I was wondering why I was here 🙃 😂

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Feb 29, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Feb 29, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Mar 7, 2024
@melvin-bot melvin-bot bot changed the title [MEDIUM] Ensure that we preserve order of tags for multiple levels of tag lists [HOLD for payment 2024-03-14] [MEDIUM] Ensure that we preserve order of tags for multiple levels of tag lists Mar 7, 2024
Copy link

melvin-bot bot commented Mar 7, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Mar 7, 2024
Copy link

melvin-bot bot commented Mar 7, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.48-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-03-14. 🎊

Copy link

melvin-bot bot commented Mar 7, 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:

  • [@yuwenmemon] The PR that introduced the bug has been identified. Link to the PR:
  • [@yuwenmemon] 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:
  • [@yuwenmemon] 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:
  • [@yuwenmemon] Determine if we should create a regression test for this bug.
  • [@yuwenmemon] 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.
  • [] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Mar 14, 2024
Copy link

melvin-bot bot commented Mar 14, 2024

Skipping the payment summary for this issue since all the assignees are employees or vendors. If this is incorrect, please manually add the payment summary SO.

@melvin-bot melvin-bot bot added the Overdue label Mar 18, 2024
Copy link

melvin-bot bot commented Mar 19, 2024

@yuwenmemon Eep! 4 days overdue now. Issues have feelings too...

@yuwenmemon
Copy link
Contributor Author

This is done, closing

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
Projects
Archived in project
Development

No branches or pull requests

3 participants