Skip to content

fix(people): respect "Send portal invite email" opt-out when adding users#3068

Merged
tofikwest merged 1 commit into
mainfrom
tofik/fix-portal-invite-checkbox
Jun 9, 2026
Merged

fix(people): respect "Send portal invite email" opt-out when adding users#3068
tofikwest merged 1 commit into
mainfrom
tofik/fix-portal-invite-checkbox

Conversation

@tofikwest

@tofikwest tofikwest commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Bug

On the People page, adding a user via + Add User and unchecking "Send portal invite email" still emailed the new user. The checkbox appeared to have no effect.

Root cause

The frontend (InviteMembersModal) and the API DTO both pass sendPortalEmail through correctly. The defect is in apps/api/src/people/people-invite.service.tsaddEmployeeWithoutInvite() (the path taken for strictly-employee roles, i.e. the common People-page case):

if (sendPortalEmail) {
  /* InvitePortalEmail */          // checked  → portal email ✅
} else {
  const inviteLink = this.buildPortalUrl(organizationId);
  await triggerEmail({ ..., react: InviteEmail({ organizationName, inviteLink }) }); // UNCHECKED → STILL EMAILS ❌
}

The checkbox wasn't ignored — the else branch was written to send a different email (an InviteEmail containing a portal link) instead of no email. A method named addEmployeeWithoutInvite always sent an invite.

Fix

  • Send the portal invite email only when requested. When opted out, the member is added silently with no email.
  • The caller no longer surfaces emailSent for an intentional skip, so the modal's "invite email could not be sent" warning (which keys off emailSent === false) doesn't fire when the admin deliberately suppressed the email.

Non-employee invites (admin/auditor/etc.) are unchanged — they still receive the app invitation needed to accept and join; the "Send portal invite email" toggle only governs the portal email.

Tests

apps/apinpx jest src/people/people-invite.service.spec.ts19 passed.

  • Added a regression test: employee + portal unchecked → member created, no email of any kind sent, no false emailSent signal.
  • Updated two existing specs that asserted the old always-send behavior.

Notes for reviewer

  • Scope is intentionally minimal: 2 files (people-invite.service.ts + its spec).
  • npx turbo run typecheck --filter=@trycompai/api surfaces pre-existing errors in unrelated specs (variables.controller, sync-gws.controller, risks, timelines, training, offboarding) — none in people, none introduced by this PR. Left untouched to keep the fix focused.

🤖 Generated with Claude Code


Summary by cubic

Fixes the People page flow so unchecking "Send portal invite email" adds the user without emailing them. Also prevents the modal from showing a false "invite email could not be sent" warning when the admin opts out.

  • Bug Fixes
    • Only send the portal invite when sendPortalEmail === true; unchecked adds the member silently.
    • Return emailSent only when an email send was attempted to avoid false modal warnings.
    • Added a regression test and updated two specs to cover the opt-out path.

Written for commit 18144fd. Summary will update on new commits.

Review in cubic

…sers

When adding a user via "+ Add User" on the People page, unchecking
"Send portal invite email" did not suppress the email. The frontend and
DTO correctly passed sendPortalEmail through, but addEmployeeWithoutInvite
(taken for strictly-employee roles) still emailed the user in its else
branch — sending an InviteEmail with a portal link instead of nothing.

Now the portal invite email is sent only when requested. When opted out,
the member is added silently. The caller also stops surfacing emailSent on
an intentional skip, so the UI's "invite email could not be sent" warning
no longer fires when the admin deliberately suppressed the email.

Updates two existing specs that asserted the old always-send behavior and
adds a regression test for the employee opt-out path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comp-framework-editor Ready Ready Preview, Comment Jun 9, 2026 8:39pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
app Skipped Skipped Jun 9, 2026 8:39pm
portal Skipped Skipped Jun 9, 2026 8:39pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@tofikwest tofikwest merged commit 4c9c19e into main Jun 9, 2026
11 checks passed
@tofikwest tofikwest deleted the tofik/fix-portal-invite-checkbox branch June 9, 2026 20:47
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.74.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

2 participants