diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx index 55d773b9f8fe..2e786224778e 100644 --- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx +++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx @@ -297,29 +297,28 @@ function ThreadNavigationSidebarPane( ), [threadListV2Enabled, projects, selectedProjectRefs], ); + // Not short-circuited on v2 the way `scopedProjects` is: the project + // sections below partition these same lists, so emptying them here leaves + // every section with no rows and the sidebar blank. const scopedThreads = useMemo( () => - threadListV2Enabled - ? [] - : selectedProjectRefs === null - ? threads - : threads.filter((thread) => - selectedProjectRefs.has(scopedProjectKey(thread.environmentId, thread.projectId)), - ), - [threadListV2Enabled, selectedProjectRefs, threads], + selectedProjectRefs === null + ? threads + : threads.filter((thread) => + selectedProjectRefs.has(scopedProjectKey(thread.environmentId, thread.projectId)), + ), + [selectedProjectRefs, threads], ); const scopedPendingTasks = useMemo( () => - threadListV2Enabled - ? [] - : selectedProjectRefs === null - ? pendingTasks - : pendingTasks.filter((pendingTask) => - selectedProjectRefs.has( - scopedProjectKey(pendingTask.environmentId, pendingTask.projectId), - ), + selectedProjectRefs === null + ? pendingTasks + : pendingTasks.filter((pendingTask) => + selectedProjectRefs.has( + scopedProjectKey(pendingTask.environmentId, pendingTask.projectId), ), - [threadListV2Enabled, pendingTasks, selectedProjectRefs], + ), + [pendingTasks, selectedProjectRefs], ); const groups = useMemo( () => diff --git a/apps/mobile/src/features/threads/threadListV2.test.ts b/apps/mobile/src/features/threads/threadListV2.test.ts index d1389a0a909c..4c750e58435f 100644 --- a/apps/mobile/src/features/threads/threadListV2.test.ts +++ b/apps/mobile/src/features/threads/threadListV2.test.ts @@ -1069,6 +1069,20 @@ describe("buildThreadListV2ProjectSectionItems", () => { settledShelfExpanded: true, }); + // A regression guard: the sidebar once fed these sections an empty thread + // list, which drops every header too and leaves the whole sidebar blank. + it("drops a project entirely when it is handed no threads", () => { + const populated = buildThreadListV2ProjectSectionItems({ + sections: [section("alpha", ["a1"]), section("beta", ["b1"])], + }); + expect(populated.filter((item) => item.type === "v2-project-header")).toHaveLength(2); + + const starved = buildThreadListV2ProjectSectionItems({ + sections: [section("alpha", []), section("beta", [])], + }); + expect(starved).toEqual([]); + }); + it("puts every project's rows under its own header, in section order", () => { const items = buildThreadListV2ProjectSectionItems({ sections: [section("alpha", ["a1"]), section("beta", ["b1", "b2"])],