Skip to content

Commit 4735d22

Browse files
committed
fix(inbox): make "Entire project" scope show project-wide reports
The report-list ordering always appended `-is_suggested_reviewer`, floating the current user's reports to the top of every page. Since only the first page (100 reports) is loaded, the "Entire project" scope showed nothing but the user's own reports — identical to "For you". Drop the `-is_suggested_reviewer` ordering tiebreak and instead apply the reviewer scope server-side via the existing `suggested_reviewers` param: "For you" now filters on the current user's uuid, teammate scopes on theirs, and "Entire project" sends nothing so the whole project comes back. Generated-By: PostHog Code Task-Id: 715efc4f-94d6-44a6-a85b-ececa0905c66
1 parent 2b4cf36 commit 4735d22

3 files changed

Lines changed: 38 additions & 10 deletions

File tree

packages/core/src/inbox/reportFiltering.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,27 @@ describe("filterReportsBySearch", () => {
9898
});
9999

100100
describe("buildSignalReportListOrdering", () => {
101-
it("puts status then suggested reviewer then descending field", () => {
101+
it("puts status then descending field", () => {
102102
expect(buildSignalReportListOrdering("total_weight", "desc")).toBe(
103-
"status,-is_suggested_reviewer,-total_weight",
103+
"status,-total_weight",
104104
);
105105
});
106106

107-
it("puts status then suggested reviewer then ascending field", () => {
107+
it("puts status then ascending field", () => {
108108
expect(buildSignalReportListOrdering("created_at", "asc")).toBe(
109-
"status,-is_suggested_reviewer,created_at",
109+
"status,created_at",
110110
);
111111
});
112112

113113
it("works for signal_count", () => {
114114
expect(buildSignalReportListOrdering("signal_count", "desc")).toBe(
115-
"status,-is_suggested_reviewer,-signal_count",
115+
"status,-signal_count",
116+
);
117+
});
118+
119+
it("does not float the current user's reports via ordering", () => {
120+
expect(buildSignalReportListOrdering("priority", "asc")).not.toContain(
121+
"is_suggested_reviewer",
116122
);
117123
});
118124
});

packages/core/src/inbox/reportFiltering.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ export function buildStatusFilterParam(statuses: SignalReportStatus[]): string {
5959
/**
6060
* Comma-separated `ordering` for the signal report list API:
6161
* 1. Status rank (ready first – semantic server-side rank, always applied)
62-
* 2. Suggested reviewer (current user's reports first)
63-
* 3. Toolbar-selected field (priority, total_weight, created_at, etc.)
62+
* 2. Toolbar-selected field (priority, total_weight, created_at, etc.)
63+
*
64+
* The reviewer scope is applied via the `suggested_reviewers` query param, not
65+
* ordering — a `-is_suggested_reviewer` tiebreak would float the current user's
66+
* reports to the top of the first page and starve the "Entire project" scope of
67+
* non-self reports (only the first page is loaded).
6468
*/
6569
export function buildSignalReportListOrdering(
6670
field: SignalReportOrderingField,
6771
direction: "asc" | "desc",
6872
): string {
6973
const fieldKey = direction === "desc" ? `-${field}` : field;
70-
return `status,-is_suggested_reviewer,${fieldKey}`;
74+
return `status,${fieldKey}`;
7175
}
7276

7377
export function buildSuggestedReviewerFilterParam(

packages/ui/src/features/inbox/hooks/useInboxAllReports.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import {
88
} from "@posthog/core/inbox/reportFiltering";
99
import {
1010
computeInboxTabCounts,
11+
INBOX_SCOPE_FOR_YOU,
1112
matchesReviewerScope,
1213
parseTeammateInboxScope,
1314
} from "@posthog/core/inbox/reportMembership";
15+
import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
16+
import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
1417
import { useInboxReportsInfinite } from "@posthog/ui/features/inbox/hooks/useInboxReports";
1518
import { useInboxReviewerScopeStore } from "@posthog/ui/features/inbox/stores/inboxReviewerScopeStore";
1619
import { useInboxSignalsFilterStore } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
@@ -52,7 +55,22 @@ export function useInboxAllReports(options?: {
5255
const priorityFilter = useInboxSignalsFilterStore((s) =>
5356
ignoreFilters ? EMPTY_FILTER_ARRAY : s.priorityFilter,
5457
);
58+
const client = useOptionalAuthenticatedClient();
59+
const { data: currentUser } = useCurrentUser({ client });
60+
61+
// The reviewer scope is applied server-side via `suggested_reviewers`.
62+
// "For you" filters on the current user's uuid; a teammate scope on theirs;
63+
// "Entire project" (and the Runs tab's `ignoreScope`) send nothing so the
64+
// whole project comes back. This replaces the old `-is_suggested_reviewer`
65+
// ordering tiebreak, which floated the current user's reports to the top of
66+
// the first (and only loaded) page and made "Entire project" look identical
67+
// to "For you".
5568
const teammateUuid = ignoreScope ? null : parseTeammateInboxScope(scope);
69+
const reviewerUuid =
70+
teammateUuid ??
71+
(!ignoreScope && scope === INBOX_SCOPE_FOR_YOU
72+
? (currentUser?.uuid ?? null)
73+
: null);
5674

5775
const query = useInboxReportsInfinite(
5876
{
@@ -63,8 +81,8 @@ export function useInboxAllReports(options?: {
6381
? sourceProductFilter.join(",")
6482
: undefined,
6583
priority: buildPriorityFilterParam(priorityFilter),
66-
suggested_reviewers: teammateUuid
67-
? buildSuggestedReviewerFilterParam([teammateUuid])
84+
suggested_reviewers: reviewerUuid
85+
? buildSuggestedReviewerFilterParam([reviewerUuid])
6886
: undefined,
6987
},
7088
{

0 commit comments

Comments
 (0)