Skip to content

fix: resolve Slack/WorkOS leader IDs for chapter event management#688

Merged
bokelley merged 2 commits into
mainfrom
bokelley/david-event-mgmt-fix
Jan 9, 2026
Merged

fix: resolve Slack/WorkOS leader IDs for chapter event management#688
bokelley merged 2 commits into
mainfrom
bokelley/david-event-mgmt-fix

Conversation

@bokelley

@bokelley bokelley commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix chapter leader permission checks for users added via Slack ID before linking WorkOS
  • David (Germany Chapter leader) couldn't manage events because his leader record stored his Slack user ID, but login uses WorkOS ID
  • Now resolves user IDs at read time via slack_user_mappings table JOIN

Changes

  • getLeaders / getLeadersBatch: Use COALESCE(sm.workos_user_id, wgl.user_id) to resolve canonical ID
  • isLeader: Check both wgl.user_id = $1 OR sm.workos_user_id = $1
  • getCommitteesLedByUser: Same bidirectional check
  • content.ts: Fix is_leader subqueries in collections and pending content
  • member-context.ts: Fix leader query for pending content
  • outbound-db.ts: Fix capability count queries

Test plan

  • All 187 tests pass
  • TypeScript type checking passes
  • Verify David can manage events on Germany Chapter page after deploy

🤖 Generated with Claude Code

bokelley and others added 2 commits January 9, 2026 14:05
Chapter leaders added via Slack ID before linking their WorkOS account
couldn't manage events because the leader permission checks compared
stored Slack IDs against login WorkOS IDs.

Changes:
- getLeaders/getLeadersBatch: Resolve canonical_user_id via slack_user_mappings
- isLeader: Check both direct user_id match and Slack→WorkOS mapping
- getCommitteesLedByUser: Support both ID types with DISTINCT count
- content.ts: Fix is_leader subqueries to use mapping join
- member-context.ts: Fix pending content leader query
- outbound-db.ts: Fix capability counts for leaders

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Based on code review feedback:
- Remove redundant resolveToCanonicalUserId() calls in isLeader() and
  getCommitteesLedByUser() since the JOIN handles ID resolution
- Add consistent AND sm.workos_user_id IS NOT NULL to all JOINs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley bokelley merged commit bdc8270 into main Jan 9, 2026
6 checks passed
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.

1 participant