import { STAFF_WORKSPACES } from './staffRoleCatalog'; /** * Workspaces permitted to reach the shared staff messaging surface * (`/dashboard/staff-messages`, colleague colleague). **Every real staff * workspace** - deliberately EXCLUDES only the `GENERIC` fallback (as the * built-in-workspace route guard also does; unlike that guard, this set * additionally admits HR, Billing and Marketing) and all non-staff resources * (Patient / RelatedPerson). * * `MARKETING` was MISSING here until 2026-08-10 (found by the card-133 * reachability audit; Spencer: *"each staff workspace should have staff * messaging"*). It is the SECOND list this member was added late to and then * left out of - see the comment on `STAFF_WORKSPACES.MARKETING`, which records * it being added to `PERMISSION_DRIVEN_WORKSPACES` but never to that union, * leaving the entry dead. * * No test caught it: the suite named the six and asserted that * `Generic`/`Patient`/`RelatedPerson`/unknown are rejected, so `Marketing` fell * into the "unknown rejected" branch and stayed green. The test now derives * its expectation from `STAFF_WORKSPACES` itself, so a NINTH workspace added * later fails loudly here instead of silently losing messaging. */ const STAFF_MESSAGING_WORKSPACES: readonly string[] = [ STAFF_WORKSPACES.PRACTITIONER, STAFF_WORKSPACES.RECEPTIONIST, STAFF_WORKSPACES.ADMIN, STAFF_WORKSPACES.PLATFORM_MANAGER, STAFF_WORKSPACES.HR, STAFF_WORKSPACES.BILLING, STAFF_WORKSPACES.MARKETING, /* * - `GENERIC` ADDED, and the exclusion above is struck rather than quietly dropped. * * Spencer, 2026-08-16: *"Of course they should be able to message colleagues, that's why **all * staff roles** should have access to the messaging system."* * * It was excluded for being a *fallback* rather than a real workspace. That reading is now the * wrong one: `Generic` is what a DELEGATED staffer with no specific hat lands in, and those are * exactly the people the ruling is about. Server-side it maps to the `Staff` Cognito group and * carries the same grant every other hat here does. * **Leaving it out would have made the client and the server disagree about a product decision - * the server admitting them and this guard redirecting them away - which is the shape of the very * contradiction was raised to remove**, reversed. * The non-staff resources (Patient / RelatedPerson) are still excluded and always will be. */ STAFF_WORKSPACES.GENERIC, /* * - Referrals. Spencer's ruling above is unqualified: *"all staff roles"* have messaging, * and a referral coordinator is a staff role. It is also the hat that most obviously needs it - the * whole job is chasing people about a patient's referral, and the colleague they chase most often is * the practitioner who placed the order. */ STAFF_WORKSPACES.REFERRALS, /* * The diagnostic hats, on the same unqualified ruling: *"all staff roles"* have messaging. A tech * chasing the practitioner who placed an order -- about a specimen that arrived haemolysed, or a * study the patient did not attend -- is the same job the coordinator does about a referral. */ STAFF_WORKSPACES.LAB_TECH, STAFF_WORKSPACES.IMAGING_TECH, STAFF_WORKSPACES.RECORDS, ]; export const isStaffMessagingWorkspace = ( workspace: string | null | undefined, ): boolean => !!workspace && STAFF_MESSAGING_WORKSPACES.includes(workspace);