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
5 changes: 3 additions & 2 deletions src/libs/CategoryOptionListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function sortCategories(categories: Record<string, Category>, localeCompare: Loc
...existedValue,
name: category.name,
pendingAction: category.pendingAction,
enabled: category.enabled ?? false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve subcategories named "enabled"

Storing enabled directly on each hierarchy node makes enabled a reserved key, so any category segment literally named enabled is treated as metadata instead of a child. In flatHierarchy, destructuring pulls enabled out and excludes it from subcategories, which can drop categories like "Travel: enabled" (or corrupt a parent node when both "Travel" and "Travel: enabled" exist), causing valid categories to disappear from the picker.

Useful? React with 👍 / 👎.

});
}

Expand All @@ -255,12 +256,12 @@ function sortCategories(categories: Record<string, Category>, localeCompare: Loc
*/
const flatHierarchy = (initialHierarchy: Hierarchy) =>
Object.values(initialHierarchy).reduce((acc: Category[], category) => {
const {name, pendingAction, ...subcategories} = category;
const {name, pendingAction, enabled, ...subcategories} = category;
if (name) {
const categoryObject: Category = {
name,
pendingAction,
enabled: categories[name]?.enabled ?? false,
enabled: enabled ?? false,
};

acc.push(categoryObject);
Expand Down
Loading