You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD] Categories - Category moves to the bottom after editing the name #62184
Version Number: 9.1.46-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: Exp Email or phone of affected tester (no customers):applausetester+sj8snd91@applause.expensifail.com Issue reported by: Applause Internal Team Device used: Mac 15.3 / Chrome App Component: Workspace Settings
Action Performed:
Go to staging.new.expensify.com
Go to workspace settings > Categories.
Click Advertising.
Edit the name to Advertisement and save it.
Expected Result:
The category will reorder alphabetically after editing the name.
Actual Result:
The category moves to the bottom of the list after editing the name.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can test useSearchResults and verify the result is correct when the list value is changed and the search value isn't changed.
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.
changed the title [-]Categories - Category moves to the bottom after editing the name[/-][+][HOLD] Categories - Category moves to the bottom after editing the name[/+]on May 16, 2025
Since we have new policyCategories this useMemo's callback is being called here we're not sorting the categories. We should sort the categories in the useMemo's callback. Not where@nkdengineer is suggesting. Because useSearchResults custom-hook should be used only for filtering the search results and then sorting them. Not when we are rendering new category list with potential edited category value. I have just started making proposals and just getting into the codebase so, @nkdengineer, feel free to correct me brother.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can check if the filteredCategoryList categories are sorted when rendering.
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.
Here we're sort of mixing filtering search result with sorting.
We can creat a new custom hook that only takes care of sorting.
We can first filter out by using useSearchResults like so:
@nlemma, Also when digging for the bug I found we're sorting results in a weird way.
whenever we have a lowercase string for a category it goes to the bottom. Is it suppose to be like that? Below is the video after I implemented my changes it works for capitalized words but not when the string is all lowercase. This is I think happening because of the way we're sorting with lodash. I'm not sure if it's a bug or a feature. Thank you.
Activity
melvin-bot commentedon May 16, 2025
Triggered auto assignment to @miljakljajic (
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.nkdengineer commentedon May 16, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Category moves to the bottom after editing the name
What is the root cause of that problem?
When the search value isn't change, we set the result as the filtered without sorting.
App/src/hooks/useSearchResults.ts
Lines 20 to 24 in 9e0ae4f
What changes do you think we should make in order to solve the problem?
We should short the filter here
App/src/hooks/useSearchResults.ts
Lines 20 to 24 in 9e0ae4f
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can test
useSearchResultsand verify the result is correct when the list value is changed and the search value isn't changed.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.
twilight2294 commentedon May 16, 2025
Regression from:
@daledah @thesahindia
daledah commentedon May 16, 2025
I've included a fix in #61656
miljakljajic commentedon May 16, 2025
Let's hold this until we're sure it's resolved by #61656 - thanks @daledah
[-]Categories - Category moves to the bottom after editing the name[/-][+][HOLD] Categories - Category moves to the bottom after editing the name[/+]miljakljajic commentedon May 19, 2025
Holding as per ^
aadil42 commentedon May 20, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
After editing the Category it moves to the bottom because the category list is not being sorted after editing.
What is the root cause of that problem?
When the WorkspaceCategoriesPage is re-rendred after we edit the category, we are getting the new categories here in WorkspaceCategoriesPage
src/pages/workspace/categories/WorkspaceCategoriesPage
Since we have new policyCategories this useMemo's callback is being called here we're not sorting the categories. We should sort the categories in the useMemo's callback. Not where @nkdengineer is suggesting. Because useSearchResults custom-hook should be used only for filtering the search results and then sorting them. Not when we are rendering new category list with potential edited category value. I have just started making proposals and just getting into the codebase so, @nkdengineer, feel free to correct me brother.
src/pages/workspace/categories/WorkspaceCategoriesPage
What changes do you think we should make in order to solve the problem?
We can simply sort the categories like so in the useMemo's callback.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can check if the filteredCategoryList categories are sorted when rendering.
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.
Here we're sort of mixing filtering search result with sorting.
We can creat a new custom hook that only takes care of sorting.
We can first filter out by using useSearchResults like so:
then we can just sort it maybe like so:
then we can use
sortedCategoryListinstead offilteredCategoryListwhen passing it as a prop here:
src/pages/workspace/categories/WorkspaceCategoriesPage
aadil42 commentedon May 20, 2025
@nlemma, Also when digging for the bug I found we're sorting results in a weird way.
whenever we have a lowercase string for a category it goes to the bottom. Is it suppose to be like that? Below is the video after I implemented my changes it works for capitalized words but not when the string is all lowercase. This is I think happening because of the way we're sorting with lodash. I'm not sure if it's a bug or a feature. Thank you.
Screen.Recording.2025-05-20.at.6.mp4
miljakljajic commentedon Jun 2, 2025
Ah - yes, this is a bug, but it's about to be fixed: #61156