diff --git a/apps/web/src/vault/individual-vault/vault-filter/services/vault-filter.service.ts b/apps/web/src/vault/individual-vault/vault-filter/services/vault-filter.service.ts index eab891b04b..27e3ab918d 100644 --- a/apps/web/src/vault/individual-vault/vault-filter/services/vault-filter.service.ts +++ b/apps/web/src/vault/individual-vault/vault-filter/services/vault-filter.service.ts @@ -215,15 +215,16 @@ export class VaultFilterService implements VaultFilterServiceAbstraction { storedFolders: FolderView[], org?: Organization ): Promise { - if (org?.id == null) { + // If no org or "My Vault" is selected, show all folders + if (org?.id == null || org?.id == "MyVault") { return storedFolders; } + + // Otherwise, show only folders that have ciphers from the selected org and the "no folder" folder const ciphers = await this.cipherService.getAllDecrypted(); const orgCiphers = ciphers.filter((c) => c.organizationId == org?.id); return storedFolders.filter( - (f) => - orgCiphers.filter((oc) => oc.folderId == f.id).length > 0 || - ciphers.filter((c) => c.folderId == f.id).length < 1 + (f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null ); } diff --git a/libs/angular/src/vault/vault-filter/services/vault-filter.service.ts b/libs/angular/src/vault/vault-filter/services/vault-filter.service.ts index a56758a8bd..ced1b1b7e9 100644 --- a/libs/angular/src/vault/vault-filter/services/vault-filter.service.ts +++ b/libs/angular/src/vault/vault-filter/services/vault-filter.service.ts @@ -55,17 +55,19 @@ export class VaultFilterService implements DeprecatedVaultFilterServiceAbstracti buildNestedFolders(organizationId?: string): Observable> { const transformation = async (storedFolders: FolderView[]) => { let folders: FolderView[]; - if (organizationId != null) { + + // If no org or "My Vault" is selected, show all folders + if (organizationId == null || organizationId == "MyVault") { + folders = storedFolders; + } else { + // Otherwise, show only folders that have ciphers from the selected org and the "no folder" folder const ciphers = await this.cipherService.getAllDecrypted(); const orgCiphers = ciphers.filter((c) => c.organizationId == organizationId); folders = storedFolders.filter( - (f) => - orgCiphers.filter((oc) => oc.folderId == f.id).length > 0 || - ciphers.filter((c) => c.folderId == f.id).length < 1 + (f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null ); - } else { - folders = storedFolders; } + const nestedFolders = await this.getAllFoldersNested(folders); return new DynamicTreeNode({ fullList: folders,