Skip to content

[Due for payment 2025-06-11] [$250] categories-Inconsistent category order display in list & expense page #61156

Closed

Description

@mitarachim

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.1.38-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/6018886
Email or phone of affected tester (no customers): slottwo1+sa@gmail.com
Issue reported by: Applause Internal Team
Device used: Redminote note 10s android 13
App Component: Other

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Go to workspace settings - categories
  3. Create category eg: A, a , B, b
  4. Scroll the page
  5. Open a workspace chat
  6. Try to create a manual expense
  7. Click categories

Expected Result:

Category list must be displayed in same order while creating expense and in categories page.

Actual Result:

In categories page, it shows small "a" category, at the end of the list. Not showing in alphabetical order.

But while creating expense, small "a" is first displayed, then capital "A" is displayed next in the list.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

https://github.com/user-attachments/assets/a71ec20a-f690-46c1-b207-4773d6f96b83
Image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021917611980787285967
  • Upwork Job ID: 1917611980787285967
  • Last Price Increase: 2025-04-30
  • Automatic offers:
    • daledah | Contributor | 107153912
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @twisterdotcom

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 30, 2025
  2. melvin-bot commented on Apr 30, 2025

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (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.

  3. daledah commented on Apr 30, 2025

    @daledah
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-04-30 16:26:33 UTC.

    Proposal

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

    In categories page, it shows small "a" category, at the end of the list. Not showing in alphabetical order.

    What is the root cause of that problem?

    In WorkspaceCategoriesPage, we use lodashSortBy with custom compare function and option:

    const categories = lodashSortBy(Object.values(policyCategories ?? {}), 'name', localeCompare) as PolicyCategory[];

    function localeCompare(a: string, b: string) {
    return collator.compare(a, b);
    }

    const COLLATOR_OPTIONS: Intl.CollatorOptions = {usage: 'sort', sensitivity: 'base'};

    While in CategoryPicker , we use sortCategories with native Array.sort and String.prototype.localeCompare

    const sortedCategories = sortCategories(categories);

    const sortedCategories = Object.values(categories).sort((a, b) => a.name.localeCompare(b.name));

    There's a different between native Array.sort and Lodash sortBy method, see this example.

    These differences in sort method and compare function lead to inconsistent in category order between pages

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

    From this comment, we want to use native Array.sort method, so we should apply this method to WS Categories page

    const categories = lodashSortBy(Object.values(policyCategories ?? {}), 'name', localeCompare) as PolicyCategory[];

    Implement same as here

    const sortedCategories = Object.values(categories).sort((a, b) => a.name.localeCompare(b.name));

    To increase performance, we can combine the two methods to use Array.sort with localeCompare

    const categories = lodashSortBy(Object.values(policyCategories ?? {}), 'name', localeCompare) as PolicyCategory[];

    const categories = Object.values(policyCategories ?? {}).sort((a, b) => localeCompare(a.name, b.name));

    To make it consistent across the app, we should find other list items that uses sorting and use Array.sort as well. For example, tags are using lodashSortBy so we need to fix that

    function sortTags(tags: Record<string, PolicyTag | SelectedTagOption> | Array<PolicyTag | SelectedTagOption>) {
    // Use lodash's sortBy to ensure consistency with oldDot.
    return lodashSortBy(tags, 'name', localeCompare) as PolicyTag[];
    }

    const sortedTags = lodashSortBy(Object.values(policyTagLists.at(0)?.tags ?? {}), 'name', localeCompare) as PolicyTag[];

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    NA

    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.

  4. twisterdotcom commented on Apr 30, 2025

    @twisterdotcom
    Contributor

    choose one of the below methods and apply it to the other place

    Huh, interesting. I wonder which one we prefer. cc @Expensify/design - super minor but how do we want the order to look for these lists.

    Image

    @daledah does this mismatch occur in other lists at all like tags? Or are there benefits to either sort that we would notice, especially with larger lists at all?

  5. daledah commented on Apr 30, 2025

    @daledah
    Contributor

    @twisterdotcom For tags, both places use lodashSortBy

    function sortTags(tags: Record<string, PolicyTag | SelectedTagOption> | Array<PolicyTag | SelectedTagOption>) {
    // Use lodash's sortBy to ensure consistency with oldDot.
    return lodashSortBy(tags, 'name', localeCompare) as PolicyTag[];
    }

    const sortedTags = lodashSortBy(Object.values(policyTagLists.at(0)?.tags ?? {}), 'name', localeCompare) as PolicyTag[];

    Image
  6. shawnborton commented on Apr 30, 2025

    @shawnborton
    Contributor

    Hmm I think I would expect to see something like A, a, B, b as the correct order there... what are you thinking?

  7. twisterdotcom commented on Apr 30, 2025

    @twisterdotcom
    Contributor

    If there is no performance or genuinely engineering benefit to using one over the other, I agree with @shawnborton that we would like this to remain alphabetical, which I believe is sortNative: https://playcode.io/2363112

    0:(1) {name: "a"}
    1:(1) {name: "A"}
    2:(1) {name: "b"}
    3:(1) {name: "B"}
    
  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 30, 2025
  9. changed the title [-]categories-Inconsistent category order display in list & expense page[/-] [+][$250] categories-Inconsistent category order display in list & expense page[/+] on Apr 30, 2025
  10. melvin-bot commented on Apr 30, 2025

    @melvin-bot
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 30, 2025
  12. melvin-bot commented on Apr 30, 2025

    @melvin-bot

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

  13. 29 remaining items

  14. changed the title [-][$250] categories-Inconsistent category order display in list & expense page[/-] [+][Due for payment 2025-06-11] [$250] categories-Inconsistent category order display in list & expense page[/+] on Jun 4, 2025
  15. melvin-bot commented on Jun 4, 2025

    @melvin-bot

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

  16. melvin-bot commented on Jun 4, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.58-4 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 2025-06-11. 🎊

    For reference, here are some details about the assignees on this issue:

  17. melvin-bot commented on Jun 4, 2025

    @melvin-bot

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

  18. ahmedGaber93 commented on Jun 11, 2025

    @ahmedGaber93
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 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
    • 3d. QA
    • 3z. Other: Applause Internal Team
    • [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: N/A. I can't able to reach to the offending PR as those files refactored many times.

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

    • [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.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/510678

    Regression Test Proposal

    Test:

    1. Go to workspace settings - categories
    2. Create category e.g.: A, a, B, b
    3. Open a workspace chat
    4. Try to create a manual expense
    5. Click categories
    6. Verify that category list is displayed in the same order while creating expense and in workspace settings > categories page.

    Do we agree 👍 or 👎

  19. twisterdotcom commented on Jun 12, 2025

    @twisterdotcom
    Contributor

    Payment Summary:

  20. JmillsExpensify commented on Jul 11, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @ahmedGaber93

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions