fix(people): respect "Send portal invite email" opt-out when adding users#3068
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
🎉 This PR is included in version 3.74.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 passsendPortalEmailthrough correctly. The defect is inapps/api/src/people/people-invite.service.ts→addEmployeeWithoutInvite()(the path taken for strictly-employee roles, i.e. the common People-page case):The checkbox wasn't ignored — the
elsebranch was written to send a different email (anInviteEmailcontaining a portal link) instead of no email. A method namedaddEmployeeWithoutInvitealways sent an invite.Fix
emailSentfor an intentional skip, so the modal's "invite email could not be sent" warning (which keys offemailSent === 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/api→npx jest src/people/people-invite.service.spec.ts→ 19 passed.emailSentsignal.Notes for reviewer
people-invite.service.ts+ its spec).npx turbo run typecheck --filter=@trycompai/apisurfaces pre-existing errors in unrelated specs (variables.controller,sync-gws.controller,risks,timelines,training,offboarding) — none inpeople, 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.
sendPortalEmail === true; unchecked adds the member silently.emailSentonly when an email send was attempted to avoid false modal warnings.Written for commit 18144fd. Summary will update on new commits.