Skip to content

feat(mobile): forward reviewer search to the server in the inbox reviewer picker (port #2800)#2831

Open
Gilbert09 wants to merge 3 commits into
mainfrom
posthog-code/mobile-reviewer-search-server
Open

feat(mobile): forward reviewer search to the server in the inbox reviewer picker (port #2800)#2831
Gilbert09 wants to merge 3 commits into
mainfrom
posthog-code/mobile-reviewer-search-server

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Summary

Ports desktop #2800 ("fix(inbox): forward reviewer search query to the server") to the React Native / Expo mobile app.

The inbox "Add reviewer" picker previously fetched the available-reviewers list once and filtered it client-side only, so typing a name that wasn't on the already-fetched page returned no results. This forwards the search query to the server (the available_reviewers endpoint already accepts a query param), making the server the source of truth — matching #2800's intent.

Changes

  • useAvailableSuggestedReviewers now accepts a query option, includes it in the React Query queryKey (so distinct searches cache separately), and forwards it to getAvailableSuggestedReviewers(query).
  • EditReviewersSheet debounces the search input (250ms via a small useDebouncedValue hook) and passes it into the hook; the client-side filter is removed. Loading uses isFetching so the spinner shows while a server search is in flight.
  • Scoped the 60s background poll to the unfiltered list only, so transient search terms don't each spawn their own background poller.
  • ReviewerFilterSheet (no search box) is unchanged — it calls the hook with no query and keeps fetching the full list.

Scope

Mobile only — no desktop or shared-package changes.

Testing

  • New useInboxReports.test.ts verifies the hook forwards a trimmed query and omits the param when empty.
  • pnpm --filter @posthog/mobile test src/features/inbox → 52 passed.
  • Biome lint clean; typecheck clean for the changed files.

…ewer picker (port #2800)

The "Add reviewer" picker filtered the fetched reviewer list client-side, so
typing a name that wasn't on the already-fetched page returned nothing. Forward
the search query to the server (the endpoint already accepts `query`), mirroring
desktop #2800.

- useAvailableSuggestedReviewers takes a `query` option, includes it in the
  query key, and forwards it to the API.
- EditReviewersSheet debounces the search box (250ms) and passes it through,
  dropping the client-side filter; the server is now the source of truth.
- Restrict the 60s background poll to the unfiltered list so transient search
  terms don't each spawn their own poller.

Generated-By: PostHog Code
Task-Id: 5f455048-ddbe-44ca-99a5-ca0b44a3895d
@Gilbert09 Gilbert09 requested a review from a team June 22, 2026 10:42
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/inbox/components/EditReviewersSheet.tsx

Reviewed by React Doctor for commit 7e08c3a.

@greptile-apps

greptile-apps Bot commented Jun 22, 2026

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

---

### Issue 1 of 3
apps/mobile/src/features/inbox/components/EditReviewersSheet.tsx:86-95
**Spinner flickers on background poll when the reviewer list is empty**

`isFetching` is `true` for every in-flight fetch — including the 60-second background polls. If the available-reviewer list genuinely comes back empty (e.g. a small team, an org-level filter, or a permissions edge case), the "No users found" message disappears and is replaced by a spinner for the duration of every background poll.

The original code used `isLoading`, which React Query only sets `true` when there is no cached data yet (i.e. the very first fetch). Replacing it with `isFetching` removes that guard. The fix is to check `available === undefined` alongside `isFetching`, or to destructure `isLoading` from the hook return (which in v5 is `status === 'pending'`).

### Issue 2 of 3
apps/mobile/src/features/inbox/components/EditReviewersSheet.tsx:86-96
Use `available === undefined` (no data yet) to gate the spinner so it only shows on the true first-load state, not on every subsequent background poll that returns an empty list.

```suggestion
        {options.length === 0 ? (
          available === undefined && isFetching ? (
            <View className="flex-1 items-center justify-center">
              <ActivityIndicator size="large" color={themeColors.accent[9]} />
            </View>
          ) : (
            <View className="flex-1 items-center justify-center p-6">
              <Text className="text-[14px] text-gray-10">No users found</Text>
            </View>
          )
        ) : (
```

### Issue 3 of 3
apps/mobile/src/features/inbox/hooks/useInboxReports.test.ts:36-51
**Tests should be parameterised**

Both test cases exercise the same flow (input query → expected call argument) and differ only in their data. This is a good candidate for `it.each`, which keeps the logic in one place and makes adding new cases trivial.

Reviews (1): Last reviewed commit: "feat(mobile): forward reviewer search to..." | Re-trigger Greptile

Comment thread apps/mobile/src/features/inbox/components/EditReviewersSheet.tsx
Comment thread apps/mobile/src/features/inbox/components/EditReviewersSheet.tsx
Comment thread apps/mobile/src/features/inbox/hooks/useInboxReports.test.ts
Use isLoading instead of isFetching so the "No users found" empty state
isn't replaced by a spinner during background polls when the list is
genuinely empty. isLoading still covers an in-flight search because each
distinct query string is its own cache entry with no data yet.

Also parameterize the available-reviewers query-forwarding test with it.each.

Generated-By: PostHog Code
Task-Id: 5f455048-ddbe-44ca-99a5-ca0b44a3895d
Generated-By: PostHog Code
Task-Id: 3b645159-1cd8-4296-a723-61f59ae5f537
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