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

fix: Category - Recent and All sections appear when selected category is invalid with <8 categories. #38601

Merged
merged 4 commits into from
Mar 25, 2024
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
7 changes: 3 additions & 4 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,11 +993,11 @@ function getCategoryListSections(
const enabledCategories = Object.values(sortedCategories).filter((category) => category.enabled);

const categorySections: CategoryTreeSection[] = [];
const numberOfCategories = enabledCategories.length;
const numberOfEnabledCategories = enabledCategories.length;

let indexOffset = 0;

if (numberOfCategories === 0 && selectedOptions.length > 0) {
if (numberOfEnabledCategories === 0 && selectedOptions.length > 0) {
categorySections.push({
// "Selected" section
title: '',
Expand Down Expand Up @@ -1047,9 +1047,8 @@ function getCategoryListSections(

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

if (numberOfVisibleCategories < CONST.CATEGORY_LIST_THRESHOLD) {
if (numberOfEnabledCategories < CONST.CATEGORY_LIST_THRESHOLD) {
categorySections.push({
// "All" section when items amount less than the threshold
title: '',
Expand Down
Loading