Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,32 +943,32 @@ function getCategoryListSections(
return categorySections;
}

if (selectedOptions.length > 0) {
const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name);
const enabledAndSelectedCategories = sortedCategories.filter((category) => category.enabled || selectedOptionNames.includes(category.name));
const numberOfVisibleCategories = enabledAndSelectedCategories.length;

if (numberOfVisibleCategories < CONST.CATEGORY_LIST_THRESHOLD) {
categorySections.push({
// "Selected" section
// "All" section when items amount less than the threshold
title: '',
shouldShow: false,
indexOffset,
data: getCategoryOptionTree(selectedOptions, true),
data: getCategoryOptionTree(enabledAndSelectedCategories),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When one subcategory is selected other subcategories of this category are indented without parent category name causing #37774

});

indexOffset += selectedOptions.length;
return categorySections;
}

const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name);
const filteredCategories = enabledCategories.filter((category) => !selectedOptionNames.includes(category.name));
const numberOfVisibleCategories = selectedOptions.length + filteredCategories.length;

if (numberOfVisibleCategories < CONST.CATEGORY_LIST_THRESHOLD) {
if (selectedOptions.length > 0) {
categorySections.push({
// "All" section when items amount less than the threshold
// "Selected" section
title: '',
shouldShow: false,
indexOffset,
data: getCategoryOptionTree(filteredCategories),
data: getCategoryOptionTree(selectedOptions, true),
});

return categorySections;
indexOffset += selectedOptions.length;
}

const filteredRecentlyUsedCategories = recentlyUsedCategories
Expand All @@ -992,6 +992,8 @@ function getCategoryListSections(
indexOffset += filteredRecentlyUsedCategories.length;
}

const filteredCategories = enabledCategories.filter((category) => !selectedOptionNames.includes(category.name));

categorySections.push({
// "All" section when items amount more than the threshold
title: Localize.translateLocal('common.all'),
Expand Down