Skip to content

[HOLD for payment 2024-03-14] [MEDIUM] Ensure that we preserve order of tags for multiple levels of tag lists #37054

Closed

Description

@yuwenmemon

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 21, 2024
  2. self-assigned this
    on Feb 21, 2024
  3. melvin-bot commented on Feb 21, 2024

    @melvin-bot

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

  4. changed the title [-]Ensure that [/-] [+]Ensure that we preserve order of tags for multiple levels of tag lists[/+] on Feb 21, 2024
  5. 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[/+] on Feb 21, 2024
  6. flodnv commented on Feb 22, 2024

    @flodnv
    Contributor
  7. CortneyOfstad commented on Feb 26, 2024

    @CortneyOfstad
    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!

  8. flodnv commented on Feb 26, 2024

    @flodnv
    Contributor

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

    After discussing, I agree with the proposed solution

  9. 11 remaining items

  10. 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[/+] on Mar 7, 2024
  11. melvin-bot commented on Mar 7, 2024

    @melvin-bot

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

  12. melvin-bot commented on Mar 7, 2024

    @melvin-bot

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

  13. melvin-bot commented on Mar 7, 2024

    @melvin-bot

    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:
  14. melvin-bot commented on Mar 14, 2024

    @melvin-bot

    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.

  15. melvin-bot commented on Mar 19, 2024

    @melvin-bot

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

  16. yuwenmemon commented on Mar 21, 2024

    @yuwenmemon
    ContributorAuthor

    This is done, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions