diff --git a/packages/loot-core/src/server/importers/ynab4.ts b/packages/loot-core/src/server/importers/ynab4.ts index 97e04c97cba232385bed910c1cb7c6547253b8b9..e6c474e67597192832035486bf917a4f14cfbe80 100644 --- a/packages/loot-core/src/server/importers/ynab4.ts +++ b/packages/loot-core/src/server/importers/ynab4.ts @@ -71,8 +71,24 @@ async function importCategories( // on insertion order for (const category of subCategories) { if (!category.isTombstone) { + let categoryName = category.name; + + // Hidden categories have the parent category entity id + // appended to the end of the sub category name. + // The format is 'MasterCategory ` SubCategory ` entityId'. + // Remove the id to shorten the name. + if (masterCategory.name === 'Hidden Categories') { + const categoryNameParts = categoryName.split(' ` '); + + // Remove the last part, which is the entityId. + categoryNameParts.pop(); + + // Join the remaining parts with a slash between them. + categoryName = categoryNameParts.join('/').trim(); + } + const id = await actual.createCategory({ - name: category.name, + name: categoryName, group_id: entityIdMap.get(category.masterCategoryId), }); entityIdMap.set(category.entityId, id); diff --git a/upcoming-release-notes/3122.md b/upcoming-release-notes/3122.md new file mode 100644 index 0000000000000000000000000000000000000000..b60b2e12dcfac6d80a75df3c55ea0f7295037cf6 --- /dev/null +++ b/upcoming-release-notes/3122.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [alcroito] +--- + +Shorten hidden category names imported from YNAB4.