Table of Contents
17 — View as family
Technical reference. For task-based help, see the corresponding user guide.
Documentation status: complete for the current implementation
Reviewed: 2026-07-21
Primary users: authorized assigned coaches
Surfaces: mobile coach workspace and platform API
Purpose
View as family lets a coach inspect and, where explicitly permitted, work in the mobile-first family experience for one assigned family. It reuses branded family screens but carries a trusted coachView subject context, a persistent visual banner and assignment-derived permissions.
It is not authentication impersonation. The session actor remains the coach, the subject remains the family, writes are attributed to the coach, and every API call resolves authorization again.
User outcomes
| User need | Outcome |
|---|---|
| Understand the family experience | Open the same branded home, activity, analysis and artifact presentation the family uses. |
| Review a baby's records | Keep the selected baby in route state while moving between eligible family screens. |
| Correct or add a log | Write only when the assignment grants edit permission and support/organization access is current. |
| Review family notes | See family-entered notes without overwriting them; keep coach-private notes separate. |
| Leave safely | Use the visible Exit view action to return to the coach workspace. |
Entry and visual context
- The coach opens a current family from
/coachor/coach/families. - The root route is
/coach/families/:familyId/view-as. - The family home displays a Viewing as / Coach view as mode banner with the family name, family timezone and Exit view.
- Organization branding is resolved for the subject family so the coach sees the intended family-facing colour/logo context.
- Entering view-as can mark the roster's general activity summary seen; notification-feed seen state is independent.
Supported routes
| Route | Current behavior |
|---|---|
/coach/families/:familyId/view-as | Branded family home, selected baby, recent activities and navigation. |
/coach/families/:familyId/track/:activityType | View activity history and add/edit when canWriteActivities permits. |
/coach/families/:familyId/analysis | Trends/analysis when canViewAnalysis permits. |
/coach/families/:familyId/questionnaires | Read-only questionnaire collection and answers. |
/coach/families/:familyId/sleep-plans | Family-visible published plans only. |
/coach/families/:familyId/allergy-ladders | View and manage ladders according to trusted write permission. |
/coach/families/:familyId/reminders | Opens the reminder screen shell, but reminders are device-local; see the limitation below. |
/coach/families/:familyId/session-prep | Coach-specific preparation tool, linked from the family context but not a family screen. |
The selected baby's identifier is carried as ?babyId=… where the destination supports it. Tracking actions created from the family hero also append that identifier, avoiding an accidental switch to another baby.
Trusted subject context
The family summary returns a ResolvedAccessContext containing:
- the real coach
session; subjectUserfor the family;mode: coachView;- the matching assignment and organization;
- resolved family premium state; and
- explicit booleans for read, write, support-date, revoke and analysis permissions.
| Permission | Coach-view rule | User-visible effect |
|---|---|---|
canReadActivities | Active matching assignment, active organization membership, support record access and assignment canViewLogs. | Required to enter/read the family record. Denial blocks the route. |
canWriteActivities | Read access plus eligible organization and assignment canEditLogs. | Add/edit/delete controls are enabled; otherwise screens are read-only. |
canViewAnalysis | Record access, assignment canViewAnalysis and active premium analysis entitlement. | Analysis loads or shows the access/premium state. |
canManageSupportDates | Organization permits management and support entitlement remains visible. | Used by coach lifecycle tools, not as blanket family-screen write authority. |
canRevokeAssignment | False in ordinary coachView. | Revocation stays in explicit caseload workflow. |
The mobile CoachBillingRouteGate also checks coach subscription state around these routes. A client-side gate improves feedback; it does not replace subject authorization.
Activity and note behavior
- Family activities can be read only when
canReadActivitiesis true. - Coach-created and coach-edited activity mutations retain the coach as actor/update source for audit and analytics.
- Coach view cannot write a family-facing activity
note. An attempted non-empty family note is denied server-side. - Existing family notes can be shown as family-provided context.
- Coach-private baby/activity notes use separate endpoints and UI, are scoped to the genuine coach and are never merged into the family note. See Feature 19.
- Realtime activity changes cause the relevant view to refresh, with conflict handling in the underlying activity screens.
Family artifacts
- Questionnaires use the coach-family collection endpoint but the form is forced read-only.
- Sleep plans use the published-only collection, matching what the family can see rather than the coach authoring draft/history.
- Allergy ladders use family subject permissions; write controls depend on
canWriteActivities. - Analysis requires both assignment permission and premium access.
Current reminders limitation
The view-as menu currently links to/coach/families/:familyId/reminders, butRemindersScreenreceives no family identifier and reminders are stored locally on the current device. This route must not be interpreted as access to the family's reminders. It is a shell/navigation reuse, not a trusted family-reminder record view.
Messaging and synthetic-context boundary
Coach view-as is treated as a synthetic family context by the mobile chat provider. Chat inbox/composer UI is hidden there, and message sending must occur as the genuine coach from the coach chat workflow. This prevents a coach-view screen from appearing to speak as the family.
Authorization and privacy rules
- A coach can enter only a family assigned to that same coach through an active assignment.
- Active organization membership, organization state, coach billing and support record access are enforced by the platform.
- Expired/revoked relationships cannot regain records through a bookmarked view-as URL.
- A route family identifier is untrusted input. The API resolves the matching assignment and rejects mismatches.
- The visible banner is necessary user context but is not the security control.
- Family-facing notes remain family data; coach-private notes remain per-coach private data.
- Coach view-as is separate from the super-admin's owner-view-as-coach session. Neither is allowed to bypass feature-specific genuine-coach restrictions such as private notes or chat participation.
Loading and failure states
| State | Expected behavior |
|---|---|
| Family summary loading | Keep subject records hidden behind a focused loading state. |
| Cached summary refresh failure | Label cached data and offer retry rather than presenting it as current. |
| Assignment/support expired | Show denied/access state and return path; do not reveal stale records. |
| Write permission absent | Render read-only controls or deny the mutation server-side. |
| Premium analysis unavailable | Keep activity read separate and explain why analysis is unavailable. |
| Invalid activity type | Show route-not-found state and return to coach home. |
| Explicit exit | Return to /coach and remove family-view chrome/context. |
Acceptance checklist
- The banner always identifies family view-as and offers an explicit exit.
- The actor remains the coach and the subject family identifier is verified on every API operation.
- Selected-baby context survives eligible view-as navigation.
- Read/write/analysis controls follow the returned permission booleans and backend denial remains authoritative.
- Questionnaires are read-only and sleep plans are published-only in view-as.
- A coach cannot add or overwrite a family-facing activity note.
- Private notes remain visually/data-model separate and chat remains unavailable in the synthetic view-as context.
- The reminders route is not documented or represented as family reminder access.
- An expired or revoked assignment cannot be opened from a saved URL.
Source evidence
Mobile web
mobile-web/src/App.tsxmobile-web/src/components/AppShell.tsxmobile-web/src/components/FamilySideMenu.tsxmobile-web/src/routes/FamilyDashboard.tsxmobile-web/src/routes/ActivityTrackingScreen.tsxmobile-web/src/routes/AnalysisScreen.tsxmobile-web/src/routes/AllergyLaddersScreen.tsxmobile-web/src/routes/RemindersScreen.tsx
Platform and contracts
platform/packages/shared/src/access.tsplatform/apps/api/src/services/authorization-service.tsplatform/apps/api/src/services/prisma-invite-flow-service.tsplatform/apps/api/src/services/family-service.ts
