From 4e4637f8c072b34e99aaa4b936799d4a8f410b30 Mon Sep 17 00:00:00 2001 From: rafi Date: Mon, 14 Sep 2026 13:27:38 +0200 Subject: [PATCH] fix: preserve nested project tree in org projects when search is active Signed-off-by: rafi --- src/hooks/useOrgProjects.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/hooks/useOrgProjects.ts b/src/hooks/useOrgProjects.ts index 3d42e0574..37adc5e53 100644 --- a/src/hooks/useOrgProjects.ts +++ b/src/hooks/useOrgProjects.ts @@ -23,13 +23,18 @@ export const useOrgProjects = ( async (requestUrl: string) => { const data = await fetcher>(requestUrl); // the list endpoint returns plain projects; the nested tree is fetched - // lazily, so drop it here rather than pretend it is the frontend shape + // lazily, so drop it here rather than pretend it is the frontend shape. + // when searching, the endpoint already returns the tree, so keep it. return { ...data, - data: data.data.map(({ subGroupsAndAsset: _nested, ...item }) => ({ - ...item, - resourceType: "project" as const, - })), + data: data.data.map( + ({ subGroupsAndAsset, ...item }) => + ({ + ...item, + resourceType: "project" as const, + ...(isSearchActive ? { subGroupsAndAsset } : {}), + }) as SubGroupsAndAsset, + ), } satisfies Paged; }, { keepPreviousData: true },