Skip to content

fix(inbox): make "Entire project" scope show project-wide reports#2699

Merged
Twixes merged 3 commits into
mainfrom
posthog-code/inbox-entire-project-scope
Jun 16, 2026
Merged

fix(inbox): make "Entire project" scope show project-wide reports#2699
Twixes merged 3 commits into
mainfrom
posthog-code/inbox-entire-project-scope

Conversation

@oliverb123

Copy link
Copy Markdown
Contributor

Problem

Selecting the Entire project reviewer scope in the inbox still only showed reports where you are the suggested reviewer — identical to For you.

Root cause

buildSignalReportListOrdering always appended -is_suggested_reviewer, floating the current user's reports to the top of every status group. Because the inbox only loads the first page (REPORTS_PAGE_SIZE = 100, no infinite scroll wired) and projects have thousands of reports, that first page was entirely the user's own reports. Both for-you and entire-project sent no suggested_reviewers param, so the only thing distinguishing them was a client-side filter applied on top of an already user-dominated page.

Fix

Remove the always-on -is_suggested_reviewer ordering tiebreak and apply the reviewer scope server-side via the existing suggested_reviewers query param instead:

  • For yousuggested_reviewers=<current user uuid> (the float was what previously fed this scope, so it now filters explicitly).
  • Teammatesuggested_reviewers=<teammate uuid> (unchanged).
  • Entire project → no suggested_reviewers, ordered status,<field> → first page is the project-wide top reports.
  • Runs tab (ignoreScope) → unchanged (still project-wide).

ordering and suggested_reviewers are part of the React Query key, so each scope is its own cached query and switching refetches cleanly.

Files

  • packages/core/src/inbox/reportFiltering.ts — drop the -is_suggested_reviewer tiebreak.
  • packages/ui/src/features/inbox/hooks/useInboxAllReports.ts — resolve current user; filter For-you server-side by uuid.
  • packages/core/src/inbox/reportFiltering.test.ts — updated ordering expectations + guard.

Testing

  • reportFiltering unit tests pass.
  • Manual: For you still shows your suggested reports; Entire project now includes reports where you are not the suggested reviewer; a teammate scope shows that teammate's reports.

Note: full-monorepo typecheck currently has pre-existing failures from unbuilt sibling packages (@posthog/platform/*, workspace-server, zod v3/v4 mismatch), unrelated to this change.


Created with PostHog Code

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
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit c48ad48.

@oliverb123 oliverb123 requested a review from Twixes June 16, 2026 11:19
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/ui/src/features/inbox/hooks/useInboxAllReports.ts:69-73
**Double-fetch when `currentUser` is loading for "For you" scope**

When `scope === "for-you"` and `currentUser` hasn't resolved yet, `currentUser?.uuid` is `undefined`, so `reviewerUuid` evaluates to `null`. The hook immediately fires a project-wide query (no `suggested_reviewers` param). Once `currentUser` loads, the query key changes and a second, correctly-scoped query fires. The displayed list is still correct thanks to the client-side `matchesReviewerScope` guard, but an extra project-wide fetch is made on every mount — notable here because only the first page (100 reports) is loaded, meaning the initial project-wide result set is larger than needed and is then discarded.

Consider guarding the query with an `enabled` flag: `ignoreScope || scope !== INBOX_SCOPE_FOR_YOU || currentUser?.uuid != null`.

### Issue 2 of 2
packages/core/src/inbox/reportFiltering.test.ts:101-117
The three positive `buildSignalReportListOrdering` tests share the same structure and could be collapsed into a single parameterised test per the team's preference. This also makes it easy to add new field/direction combinations in one place.

```suggestion
  it.each([
    ["total_weight", "desc", "status,-total_weight"],
    ["created_at", "asc", "status,created_at"],
    ["signal_count", "desc", "status,-signal_count"],
  ] as const)(
    "orders by status then %s (%s)",
    (field, direction, expected) => {
      expect(buildSignalReportListOrdering(field, direction)).toBe(expected);
    },
  );
```

Reviews (1): Last reviewed commit: "fix(inbox): make "Entire project" scope ..." | Re-trigger Greptile

Comment thread packages/ui/src/features/inbox/hooks/useInboxAllReports.ts Outdated
Comment thread packages/core/src/inbox/reportFiltering.test.ts Outdated

@Twixes Twixes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yess

@Twixes Twixes enabled auto-merge (squash) June 16, 2026 13:17
@Twixes Twixes merged commit 2d12c62 into main Jun 16, 2026
23 checks passed
@Twixes Twixes deleted the posthog-code/inbox-entire-project-scope branch June 16, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants