Team Chat — guests in private channels
A guest invited to a private channel can now actually open it. Accepting the invitation grants membership on every channel the invitation named — the same write the "Add members" picker makes — so the private channel appears in the guest's sidebar and its messages load. Private channels stay invisible to every non-member, and a one-time backfill gives the same membership to guests who accepted before this shipped.
On this page
A guest is someone from outside the team — a contractor, a client, an agency — who is invited into one workspace and allowed into named channels only. When the channel they were invited to is private, being named on their profile was not enough: a private channel opens only for a person on its member list, and accepting the invitation never put the guest there. The guest joined the workspace, saw the channel in their sidebar, and then could not open it. That is fixed.
What the person experiences now
- The invitation names the channels in the email and on the invite card. Accepting it now gives the guest membership on each of those channels, private ones included.
- The channel appears in the guest's sidebar and its history loads straight away — no second step, no request to the owner.
- The channel shows the usual line, Dana added Tina to the channel, when the person who sent the invitation still has access to that channel. If they do not, the membership still lands and no line is posted.
- The guest can post in the channel unless the channel is read-only for them, exactly as any other member.
- Nothing else opens up. A private channel the guest was not invited to stays invisible: it is not in their sidebar, it cannot be opened by id, and its messages are refused.
What the workspace owner or admin controls
- The channel list on the invite dialog is still the only thing that decides scope — the guest gets what the invitation names, and nothing the invitation does not.
- Changing a guest's channels later still works the same way: the admin adds or replaces their channel list, and the guest's sidebar follows.
- A channel that is deleted or archived between the invitation and its acceptance grants nothing — the guest simply is not added to a channel that is no longer live.
- An agent lane (a private channel between two agents) and a direct message can never be given to a guest, and the grant refuses both.
Guests invited before this shipped
Guests who accepted an invitation to a private channel earlier are already members of the workspace but still missing from those channels. A one-time backfill fixes them, and it is safe to run more than once — it skips every channel a guest is already on, so a second run reports zero and writes nothing.
node --import ./scripts/lib/node-ts-register.mjs scripts/team-chat/backfill-guest-channel-members.mjs
node --import ./scripts/lib/node-ts-register.mjs scripts/team-chat/backfill-guest-channel-members.mjs --apply
The first line is a dry run that prints how many memberships it would grant; --apply writes them.
It needs the operator's Google credentials (gcloud auth application-default login) against the
team-chat Firestore project. The backfill posts no notice: those memberships predate the feature,
and a "someone added you" line dated today would be untrue.
For engineers
Accepting an invitation is a transaction in global-auth/guest-members.ts: it reads the invitation,
the workspace, the caller's membership and profile, refuses an expired or revoked offer, and writes
the guest member doc (with guestChannelIds) or unions the channels into an existing guest's set.
The transaction now also returns the grant it owes, and after it commits
grantGuestChannelMemberships (team-chat/guest-channel-grant.ts) applies it.
That grant is the same write the client's channel-add path makes, in one writeBatch: a
channels/{id}/channelMembers/{uid} document with role: 'member', addedBy and addedAt, plus
memberUids: arrayUnion(uid) and the recency fields on the channel document. It then posts the
membership-change / added divider per channel through postSystemMessage, authored by the person
who sent the invitation, with a deterministic clientMsgId so a retry never double-posts. A refused
notice is logged and swallowed — the membership is already committed and must not be undone by a
cosmetic failure.
The eligibility predicate is isGuestableChannelDoc in team-chat/guest-channel-targets.ts, shared
with the invite path so a channel the invite refuses can never be granted at accept time: a
channel-typed, unarchived document whose name is not a machinery lane.
Two bounds: a grant reads its channels in one getAll and caps at 100 channels, the same ceiling
guestChannelIds is bounded to, and notices post five at a time.
Deploy
- No rules change. The rules already open a private channel to
request.auth.uid in resource.data.memberUidsand let a guest read one allow-listed channel by id. - No index change. The backfill walks
organizationspages and queries each workspace'smembersbyrole == 'guest', both served by the automatic single-field indexes. - No new function. Everything ships inside the existing
globalAuth/ profile-dispatch HTTP function, so the deploy is the ordinary redeploy of that function. The backfill is a script.
Invariants this change must not break
- A private channel stays invisible to every non-member: membership is the only door, and the grant
is the only new writer of
memberUidson the server. - Only an existing guest or a joining invitee is granted; a full member who accepts a guest invitation is told they are already a member and nothing is granted.
- A failed grant never fails the acceptance: the guest is a member either way, and the failure is
logged as
teamchat_guest_channel_grant_failed.
Last verified 2026-11-20