diff --git a/ui/src/lib/inbox.test.ts b/ui/src/lib/inbox.test.ts index 7aafda5166..06fc686aa4 100644 --- a/ui/src/lib/inbox.test.ts +++ b/ui/src/lib/inbox.test.ts @@ -1054,6 +1054,25 @@ describe("inbox helpers", () => { ).toEqual(["inbox", "archived", "other"]); }); + it("omits empty archived and other ungrouped search sections", () => { + expect( + buildGroupedInboxSections( + [], + "none", + {}, + { keyPrefix: "archived-search:", searchSection: "archived" }, + ), + ).toEqual([]); + expect( + buildGroupedInboxSections( + [], + "none", + {}, + { keyPrefix: "other-search:", searchSection: "other" }, + ), + ).toEqual([]); + }); + it("defaults the remembered inbox tab to mine and persists all", () => { localStorage.clear(); expect(loadLastInboxTab()).toBe("mine"); diff --git a/ui/src/lib/inbox.ts b/ui/src/lib/inbox.ts index e6b76c640e..be0e9145f7 100644 --- a/ui/src/lib/inbox.ts +++ b/ui/src/lib/inbox.ts @@ -1126,6 +1126,9 @@ export function buildGroupedInboxSections( const keyPrefix = options?.keyPrefix ?? ""; const searchSection = options?.searchSection ?? "none"; const nestingEnabled = options?.nestingEnabled ?? false; + if (searchSection !== "none" && items.length === 0) { + return []; + } return groupInboxWorkItems(items, groupBy, workspaceGrouping).map((group) => { const nestedGroup = nestingEnabled && group.items.some((item) => item.kind === "issue")