Skip to content

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

Open
jianwei1 wants to merge 6 commits intomainfrom
jianweichong/nes-1492-google-sync-dropdown-shows-another-managers-gmail-account
Open

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

Conversation

@jianwei1
Copy link
Copy Markdown
Contributor

@jianwei1 jianwei1 commented Mar 31, 2026

Summary

  • The Google Account dropdown in the Sheets Sync Dialog was showing all team members' Google integrations, including other managers' Gmail accounts
  • Added a frontend filter using useAuth() to only display integrations belonging to the current user
  • Added tests verifying the dropdown correctly filters by user ownership

Test plan

  • All existing tests pass (8/8)
  • Verify dropdown only shows the logged-in user's Google account(s)
  • Verify "Add New Google Account" button still works
  • Verify selecting an account and creating a sync still works end-to-end

https://claude.ai/code/session_01EtYKMXcLEPLCFWaNsqw4FK

Summary by CodeRabbit

  • New Features

    • Show only the current user's Google integrations when selecting an integration account in the Google Sheets sync dialog.
  • Bug Fixes

    • Ensure the integration dropdown shows only a disabled placeholder if no matching integrations or user is not authenticated.
  • Tests

    • Added unit tests covering dropdown filtering for authenticated, unauthenticated, and no-match scenarios.
  • Localization

    • Removed an obsolete "Unknown integration" translation entry.

claude added 2 commits March 31, 2026 18:37
… (NES-1492)

The Google Account dropdown in the Sheets Sync Dialog was showing all
team members' Google integrations. Now it filters by the current user's
ID so only their own connected accounts appear.

https://claude.ai/code/session_01EtYKMXcLEPLCFWaNsqw4FK
@linear
Copy link
Copy Markdown

linear bot commented Mar 31, 2026

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 31, 2026

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 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: 009c939b-a5f9-4899-8a72-2af9c5a62a63

📥 Commits

Reviewing files that changed from the base of the PR and between 89b6c97 and 18968d5.

📒 Files selected for processing (3)
  • apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.spec.tsx
  • apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.tsx
  • libs/locales/en/apps-journeys-admin.json
💤 Files with no reviewable changes (1)
  • libs/locales/en/apps-journeys-admin.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.spec.tsx

Walkthrough

The dialog now reads the authenticated user via useAuth(), filters Google integrations to those owned by that user, and uses that filtered set for the account-selection dropdown. Tests and mocks were added to validate behavior for matching, non-matching, and unauthenticated cases.

Changes

Cohort / File(s) Summary
Google Integrations User Filtering
apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.tsx, apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.spec.tsx
Added useAuth() usage and derived currentUserId. Filtered IntegrationGoogle items to currentUserIntegrations (owner match) and updated renderValue/options to use that list. Tests: added useAuth mock, extended default integration entries with user.id, and three tests covering matching, non-matching, and unauthenticated scenarios.
Locale cleanup
libs/locales/en/apps-journeys-admin.json
Removed the "Unknown integration" translation key; fallback message now uses "Unknown email".

Sequence Diagram(s)

sequenceDiagram
    participant Dialog as GoogleSheetsSyncDialog
    participant Auth as useAuth
    participant Data as integrationsData (props)
    participant UI as Dropdown

    Dialog->>Auth: call useAuth()
    Auth-->>Dialog: return user (id or null)
    Dialog->>Data: read integrationsData.integrations
    Dialog-->>Dialog: filter integrations where integration.user.id == user.id
    Dialog->>UI: render dropdown options from filtered integrations
    UI-->>Dialog: user selects integration (or sees only placeholder)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 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 accurately describes the main change: filtering the Google sync dropdown to show only the current user's accounts, directly addressing the issue of showing other managers' accounts.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 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.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 31, 2026

View your CI Pipeline Execution ↗ for commit 7b4e9f2

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

☁️ Nx Cloud last updated this comment at 2026-03-31 22:47:09 UTC

@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 31, 2026 18:40 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: 1

🤖 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.tsx`:
- Around line 171-175: The ownership filter for myGoogleIntegrations can pass
when both integration.user?.id and user?.id are undefined; update the filter in
the myGoogleIntegrations computation to require concrete IDs before comparing by
first checking that both integration.user?.id and user?.id are non-null/defined
and then comparing equality (e.g., ensure integration.user?.id !== undefined &&
user?.id !== undefined && integration.user.id === user.id) so integrations
without an owner are excluded when auth state is unresolved.
🪄 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: a46d6933-bdff-498d-8f24-b01fec20b9b2

📥 Commits

Reviewing files that changed from the base of the PR and between 1c80b32 and 379ae7b.

📒 Files selected for processing (3)
  • apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.spec.tsx
  • apps/journeys-admin/src/components/JourneyVisitorsList/FilterDrawer/GoogleSheetsSyncDialog/GoogleSheetsSyncDialog.tsx
  • docs/nes-1492-fix-google-sync-dropdown.md

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Wed Apr 1 11:43:47 NZDT 2026

@jianwei1 jianwei1 requested a review from csiyang March 31, 2026 18:55
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 31, 2026 19:53 Inactive
… (NES-1492)

- Use type predicate to properly narrow integration union type (fixes TS2339)
- Fix import path to __generated__/GetIntegration (was missing a ../ level)
- Guard against undefined === undefined when user or integration owner is null
- Rename myGoogleIntegrations to currentUserIntegrations for clarity
- Simplify renderValue by removing redundant __typename check
- Add test for unauthenticated user edge case
- Remove unnecessary implementation plan doc

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@jianwei1 jianwei1 force-pushed the jianweichong/nes-1492-google-sync-dropdown-shows-another-managers-gmail-account branch from 89b6c97 to d1b3cbd Compare March 31, 2026 19:59
@github-actions github-actions bot requested a deployment to Preview - journeys-admin March 31, 2026 20:01 Pending
@github-actions github-actions bot temporarily deployed to Preview - watch-modern March 31, 2026 20:07 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player March 31, 2026 20:07 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 31, 2026 20:07 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 31, 2026 20:07 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 31, 2026 20:07 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 31, 2026 20:07 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 31, 2026 20:07 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch-modern ✅ Ready watch-modern preview Wed Apr 1 11:41:05 NZDT 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
player ✅ Ready player preview Wed Apr 1 11:41:17 NZDT 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Wed Apr 1 11:42:30 NZDT 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Wed Apr 1 11:42:40 NZDT 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
resources ✅ Ready resources preview Wed Apr 1 11:42:53 NZDT 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Wed Apr 1 11:42:51 NZDT 2026

@jianwei1 jianwei1 self-assigned this Mar 31, 2026
@github-actions github-actions bot temporarily deployed to Preview - player March 31, 2026 20:37 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 31, 2026 20:37 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 31, 2026 20:37 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch-modern March 31, 2026 20:37 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 31, 2026 20:37 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 31, 2026 20:37 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 31, 2026 20:37 Inactive
@jianwei1 jianwei1 requested a review from mikeallisonJS March 31, 2026 20:45
@github-actions github-actions bot temporarily deployed to Preview - watch March 31, 2026 22:39 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 31, 2026 22:39 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 31, 2026 22:39 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch-modern March 31, 2026 22:39 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player March 31, 2026 22:39 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 31, 2026 22:39 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 31, 2026 22:39 Inactive
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.

4 participants