Skip to content

fix: filter Google sync dropdown to only show current user's accounts (NES-1492)#8958

Merged
jianwei1 merged 12 commits intomainfrom
jianweichong/nes-1492-google-sync-dropdown-shows-another-managers-gmail-account
Apr 12, 2026
Merged

fix: filter Google sync dropdown to only show current user's accounts (NES-1492)#8958
jianwei1 merged 12 commits intomainfrom
jianweichong/nes-1492-google-sync-dropdown-shows-another-managers-gmail-account

Conversation

@jianwei1
Copy link
Copy Markdown
Contributor

@jianwei1 jianwei1 commented Apr 7, 2026

Summary

Bug (NES-1492): In multi-manager teams, the Google Sheets sync dropdown showed ALL team integrations — including those created by other managers.

Previous fix (#8938, reverted as #8957): Filtered by integration.user?.id === currentUserId, but this comparison always failed because integration.user.id resolves to a Prisma UUID (via federation through api-users), while useAuth().user.id is the Firebase UID. Result: dropdown showed zero integrations.

This fix: Uses the userId scalar field exposed in #8967 to filter integrations by integration.userId === currentUserId — both are Firebase UIDs, so the comparison works correctly.

Changes

  • Added userId to the GetIntegration query (kept user { id } — used by GoogleIntegrationDetails for ownership checks)
  • Updated filter in GoogleSheetsSyncDialog to compare integration.userId instead of integration.user?.id
  • Added tests for user filtering, null userId, and unauthenticated user scenarios

Dependencies

Test plan

  • Verify Google sync dropdown only shows the logged-in user's integrations
  • Verify another manager's integrations do NOT appear in the dropdown
  • Verify creating a new Google integration shows it in the dropdown
  • Verify the Team Integrations page still shows all team integrations (no regression)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Google Sheets integration dropdown now only shows integrations belonging to the authenticated user, falls back to the placeholder when none match, and excludes unaffiliated accounts.
  • Tests
    • Added tests validating dropdown behavior for matching, non-matching, null-owner, and unauthenticated scenarios.
  • Documentation
    • Added a plan describing the update to ensure integration-owner matching works reliably.

@linear
Copy link
Copy Markdown

linear bot commented Apr 7, 2026

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ jianwei1
❌ claude
You have signed the CLA already but the status is still pending? Let us recheck it.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 7, 2026

View your CI Pipeline Execution ↗ for commit 49780ee

Command Status Duration Result
nx run journeys-admin-e2e:e2e ✅ Succeeded 26s View ↗
nx run journeys-e2e:e2e ✅ Succeeded 20s View ↗
nx run watch-e2e:e2e ✅ Succeeded 19s View ↗
nx run resources-e2e:e2e ✅ Succeeded 16s View ↗
nx run videos-admin-e2e:e2e ✅ Succeeded 4s View ↗
nx run player-e2e:e2e ✅ Succeeded 3s View ↗
nx run watch-modern-e2e:e2e ✅ Succeeded 3s View ↗
nx run-many --target=vercel-alias --projects=re... ✅ Succeeded 2s View ↗
Additional runs (20) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-04-12 22:37:11 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 7, 2026

View your CI Pipeline Execution ↗ for commit 9521ed7

Command Status Duration Result
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 4s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 3s View ↗
nx run-many --target=deploy --projects=journeys ✅ Succeeded 39s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 9s View ↗
nx run-many --target=vercel-alias --projects=re... ✅ Succeeded 2s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 5s View ↗
nx run-many --target=deploy --projects=watch ✅ Succeeded 55s View ↗
Additional runs (11) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-04-07 01:15:40 UTC

@github-actions github-actions bot temporarily deployed to Preview - journeys-admin April 7, 2026 01:13 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin April 7, 2026 01:13 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources April 7, 2026 01:13 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player April 7, 2026 01:13 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys April 7, 2026 01:13 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch April 7, 2026 01:13 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch-modern April 7, 2026 01:13 Inactive
@jianwei1 jianwei1 self-assigned this Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch-modern ✅ Ready watch-modern preview Mon Apr 13 10:32:01 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Mon Apr 13 10:32:39 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Mon Apr 13 10:33:51 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
player ✅ Ready player preview Mon Apr 13 10:32:11 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
resources ✅ Ready resources preview Mon Apr 13 10:34:02 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Mon Apr 13 10:33:47 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Mon Apr 13 10:33:06 NZST 2026

@stage-branch-merger
Copy link
Copy Markdown
Contributor

I see you added the "on stage" label, I'll get this merged to the stage branch!

stage-branch-merger bot added a commit that referenced this pull request Apr 7, 2026
stage-branch-merger bot added a commit that referenced this pull request Apr 7, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 77a9adca-ac6b-48ea-a757-39abc87a5083

📥 Commits

Reviewing files that changed from the base of the PR and between 66cd70f and 49780ee.

📒 Files selected for processing (1)
  • libs/locales/en/apps-journeys-admin.json
💤 Files with no reviewable changes (1)
  • libs/locales/en/apps-journeys-admin.json

Walkthrough

Filters Google Sheets integrations in the sync dialog to only show integrations whose userId matches the authenticated Firebase UID, adds userId to the integration GraphQL fragment, updates tests to mock useAuth, and removes an unused locale key. Documentation plan added.

Changes

Cohort / File(s) Summary
Component Logic
apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.tsx
Added useAuth to obtain currentUserId, derived currentUserIntegrations by filtering integrations where integration.userId === currentUserId, and updated Select rendering to use the filtered list.
Tests
apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.spec.tsx
Mocked useAuth, reset mock per test, extended fixtures with userId and user payload, and added async tests asserting dropdown shows only current-user integrations, handles no matches, excludes userId: null, and handles unauthenticated user.
GraphQL Query
apps/journeys-admin/src/libs/useIntegrationQuery/useIntegrationQuery.ts
Updated GET_INTEGRATION fragment to include userId on IntegrationGoogle.
Localization
libs/locales/en/apps-journeys-admin.json
Removed the unused "Unknown integration" localization entry.
Docs / Plan
docs/plans/2026-04-07-001-fix-google-sync-dropdown-userid-mismatch-plan.md
Added plan describing backend schema exposure of userId, frontend codegen update, and the filtering change addressing NES-1492.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • csiyang
  • mikeallisonJS
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: filtering the Google sync dropdown to show only the current user's accounts, with the associated issue ID.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jianweichong/nes-1492-google-sync-dropdown-shows-another-managers-gmail-account

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot requested a deployment to Preview - journeys-admin April 7, 2026 03:29 Pending
@github-actions github-actions bot requested a deployment to Preview - videos-admin April 7, 2026 03:29 Pending
@github-actions github-actions bot requested a deployment to Preview - resources April 7, 2026 03:29 Pending
@github-actions github-actions bot requested a deployment to Preview - watch-modern April 7, 2026 03:29 Pending
@stage-branch-merger
Copy link
Copy Markdown
Contributor

Merge conflict attempting to merge this into stage. Please fix manually.

@jianwei1 jianwei1 force-pushed the jianweichong/nes-1492-google-sync-dropdown-shows-another-managers-gmail-account branch from 65c0e93 to b48397c Compare April 7, 2026 04:49
@stage-branch-merger
Copy link
Copy Markdown
Contributor

Merge conflict attempting to merge this into stage. Please fix manually.

@github-actions github-actions bot temporarily deployed to Preview - videos-admin April 7, 2026 04:50 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys April 7, 2026 04:50 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player April 7, 2026 04:50 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch-modern April 7, 2026 04:50 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources April 7, 2026 04:50 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin April 7, 2026 04:50 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch April 7, 2026 04:50 Inactive
@blacksmith-sh

This comment has been minimized.

stage-branch-merger bot added a commit that referenced this pull request Apr 7, 2026
@github-actions github-actions bot temporarily deployed to Preview - journeys April 7, 2026 21:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin April 7, 2026 21:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch-modern April 7, 2026 21:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player April 7, 2026 21:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch April 7, 2026 21:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin April 7, 2026 21:44 Inactive
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.spec.tsx`:
- Around line 260-371: The tests render GoogleSheetsSyncDialog directly which
skips the required test providers and MSW/Apollo stack; update each test that
calls render(<GoogleSheetsSyncDialog ... />) to wrap the component with the
prescribed provider chain (SnackbarProvider →
ApolloLoadingProvider/MockedProvider → ThemeProvider) and ensure MSW
test/mswServer.ts is initialized via the test setup (keep using setupApolloMocks
and mockUseIntegrationQuery/mockUseAuth for data but render through the
ApolloLoadingProvider helper); this will mirror runtime wiring and fix divergent
behavior in the tests.

In `@docs/plans/2026-04-07-001-fix-google-sync-dropdown-userid-mismatch-plan.md`:
- Around line 14-15: The plan text is stale: update the document to reflect that
the implemented fix no longer filters integrations by integration.user?.id
(which compared Prisma UUID to Firebase UID and always failed); change
references that say the branch filters by integration.user?.id and remove or
rewrite the note at lines 119-122 about a pending filter fix so the doc
correctly describes the current behavior and the actual fix (matching by the
correct user identifier used in the UI, e.g., the Firebase UID or the normalized
id field used by the integrations lookup); specifically search for and replace
mentions of integration.user?.id, currentUserId comparison, and the “filter fix
pending” wording so the plan accurately documents the implemented change and its
rationale.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8b38e23c-c0c4-4cbd-9c7c-0d70fdb98f2c

📥 Commits

Reviewing files that changed from the base of the PR and between 9ec4bdb and 66cd70f.

⛔ Files ignored due to path filters (1)
  • apps/journeys-admin/__generated__/GetIntegration.ts is excluded by !**/__generated__/**
📒 Files selected for processing (5)
  • apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.spec.tsx
  • apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.tsx
  • apps/journeys-admin/src/libs/useIntegrationQuery/useIntegrationQuery.ts
  • docs/plans/2026-04-07-001-fix-google-sync-dropdown-userid-mismatch-plan.md
  • libs/locales/en/apps-journeys-admin.json
💤 Files with no reviewable changes (1)
  • libs/locales/en/apps-journeys-admin.json
✅ Files skipped from review due to trivial changes (1)
  • apps/journeys-admin/src/libs/useIntegrationQuery/useIntegrationQuery.ts

@blacksmith-sh

This comment has been minimized.

@stage-branch-merger
Copy link
Copy Markdown
Contributor

Merge conflict attempting to merge this into stage. Please fix manually.

@jianwei1
Copy link
Copy Markdown
Contributor Author

jianwei1 commented Apr 8, 2026

Review feedback addressed (ee4fc7a)

Challenged:

  • GoogleSheetsSyncDialog.spec.tsx:260-371 — CodeRabbit suggests wrapping new tests with provider chain (SnackbarProvider → MockedProvider → ThemeProvider). All 6 pre-existing tests in this file use the same jest.mock() pattern to mock hooks directly. The new tests are consistent with the file's established approach. Converting the whole file to providers would be a separate refactor. See inline reply.

Skipped (optional/nit):

  • docs/plans/...plan.md:15 — CodeRabbit notes plan text is stale. Plan documents are point-in-time historical artifacts; the implementation is the source of truth. Updating doc prose to match final code is low-value busywork.

@stage-branch-merger
Copy link
Copy Markdown
Contributor

Merge conflict attempting to merge this into stage. Please fix manually.

@blacksmith-sh

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants