Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
16 KiB
16 KiB
Scratchpad — Teams V2: Org Hierarchy + Operational Teams
- Plan slug:
teams-v2 - Created:
2026-02-26
Decisions
- (2026-02-26) Split current "teams" into two concepts: "Reports To" (org hierarchy) and "Teams" (functional/operational groups). Existing teams stay as operational groups.
- (2026-02-26)
reports_toauto-seeded from existing team data. Safe because all active tenants with multi-team users have the same manager across teams. Atlas ICT (the only exception) canceled their subscription. - (2026-02-26) Team assignment uses hybrid approach:
assigned_team_idas metadata on ticket/task + expand members intoticket_resourcesfor actual work assignment. - (2026-02-26) New
UserAndTeamPickercomponent (Option B) instead of modifying existingUserPicker. Swapped via feature flag at call site. - (2026-02-26) Team removal dialog with radio/checkbox options: remove all, keep all, or individual selection.
- (2026-02-26) "Assigned To" filter enhanced to include teams (no separate team filter).
- (2026-02-26) "Reports To" UI placed in User Management (user edit form + org chart tab), not a separate Settings page.
- (2026-02-26) All UI elements gated behind
teams-v2PostHog feature flag. Schema migrations are not gated. - (2026-02-26) No team logos — just team name + generic team icon, following existing chip style.
- (2026-02-26) Team and individual agents are independent — adding/removing individual agents never triggers team removal.
Discoveries / Constraints
- (2026-02-26) 40 teams in production across all tenants. Most users in exactly 1 team.
- (2026-02-26)
ticket_resourceshas DB constraintassigned_to != additional_user_id— team lead must NOT be added as resource when they are the primary assignee. - (2026-02-26) Deletion config at
packages/core/src/config/deletion/index.tsalready referencestickets.assigned_team_id(column doesn't exist yet — will be created by our migration). - (2026-02-26)
TicketProperties.tsxhas a commented-out team section — can be activated for team badge display. - (2026-02-26)
projects.create_taskworkflow action already supportsassignee.type = 'team'— resolves manager_id.tickets.createdoes not. - (2026-02-26)
isManagerOfSubject()intimeEntryDelegationAuth.tsis the core approval check — joins teams → team_members. - (2026-02-26)
fetchTimeSheetsForApproval()intimeSheetActions.tsfilters byteams.manager_id = current_user. - (2026-02-26) Feature flags use
useFeatureFlag('flag-name')hook frompackages/ui/src/hooks/useFeatureFlag.tsx. - (2026-02-26)
UserPickeris atpackages/ui/src/components/UserPicker.tsx, takesvalue,onValueChange,users,size, etc. - (2026-02-26) Additional Agents use
MultiUserPickerwith chips: avatar + name + X button,bg-gray-100 rounded-fullstyle. - (2026-02-26) Ticket list filter uses
MultiUserPickerwithfilterMode={true}andselectedAssigneesstate inTicketingDashboard.tsx. - (2026-02-26) Several API endpoints in
TeamService.tsreference non-existent tables and will crash:team_hierarchy,team_permissions,project_team_assignments,task_assignments. - (2026-02-26)
getTeamAnalytics()andgetTeamCapacity()return hardcoded/mocked data.
Commands / Runbooks
- Production query to check multi-team users:
SELECT tenant, count(user_id) FROM team_members GROUP BY tenant, user_id HAVING count(team_id) > 1; - Detailed multi-team query:
WITH multi_team_users AS ( SELECT tenant, user_id FROM team_members GROUP BY tenant, user_id HAVING count(team_id) > 1 ) SELECT t.company_name, tm.team_name, mgr.first_name || ' ' || mgr.last_name AS team_manager, u.first_name || ' ' || u.last_name AS member_name FROM team_members tmem JOIN teams tm ON tm.team_id = tmem.team_id AND tm.tenant = tmem.tenant JOIN users u ON u.user_id = tmem.user_id AND u.tenant = tmem.tenant JOIN tenants t ON t.tenant = tmem.tenant LEFT JOIN users mgr ON mgr.user_id = tm.manager_id AND mgr.tenant = tm.tenant JOIN multi_team_users mtu ON mtu.user_id = tmem.user_id AND mtu.tenant = tmem.tenant ORDER BY t.company_name, tm.team_name, u.last_name;
Links / References
- Analysis document:
.ai/teams_improvements/teams_analysis_and_suggestions.md - Team model:
packages/teams/src/models/team.ts - Team actions:
packages/teams/src/actions/team-actions/teamActions.ts - Timesheet approval:
packages/scheduling/src/actions/timeSheetActions.ts - Delegation auth:
packages/scheduling/src/actions/timeEntryDelegationAuth.ts - TicketProperties (Agent team card):
packages/tickets/src/components/ticket/TicketProperties.tsx - Ticket resource actions:
packages/tickets/src/actions/ticketResourceActions.ts - UserPicker:
packages/ui/src/components/UserPicker.tsx - MultiUserPicker:
packages/ui/src/components/MultiUserPicker.tsx - Ticket list dashboard:
packages/tickets/src/components/TicketingDashboard.tsx - Feature flag hook:
packages/ui/src/hooks/useFeatureFlag.tsx - Deletion config:
packages/core/src/config/deletion/index.ts - Workflow projects action:
shared/workflow/runtime/actions/businessOperations/projects.ts - Workflow tickets action:
shared/workflow/runtime/actions/businessOperations/tickets.ts - Initial schema migration:
server/migrations/202409071803_initial_schema.cjs
Open Questions
- (None remaining — all questions resolved during analysis phase)
Updates
- (2026-02-26) Added migration
server/migrations/20260226170000_add_reports_to_to_users.cjsto create nullableusers.reports_towith FK tousers.user_id. - (2026-02-26) Added migration
server/migrations/20260226170500_seed_reports_to_from_teams.cjsto backfillusers.reports_tofrom team membership and manager_id (skips self, respects existing values). - (2026-02-26) Added server-side cycle prevention in
packages/users/src/actions/user-actions/userActions.tsforreports_toupdates (self-reference + recursive chain detection). - (2026-02-26) Added optional
reports_toto canonical IUser interfaces inshared/interfaces/user.interfaces.tsandpackages/types/src/interfaces/user.interfaces.ts. - (2026-02-26) Added Reports To dropdown to User Management details (
server/src/components/settings/general/UserDetails.tsx) behindteams-v2, with tenant user list, clearable selection, and save wiring. - (2026-02-26) Reports To selection now saved via
updateUserwhenteams-v2is enabled (cycle validation enforced server-side). - (2026-02-26) Reports To field rendering is gated behind
teams-v2feature flag. - (2026-02-26) Added Org Chart view to User Management (
server/src/components/settings/general/UserManagement.tsx) using reports_to hierarchy; roots include users with null/missing reports_to and rendering is gated byteams-v2. - (2026-02-26) Added
User.isInReportsToChaininpackages/db/src/models/user.tsusing a recursive CTE and refactored reports_to cycle check to use it. - (2026-02-26) Extended timesheet delegation auth to honor
reports_tochain whenteams-v2is enabled (usingUser.isInReportsToChain). - (2026-02-26)
fetchTimeSheetsForApprovalnow includes reports_to subordinates whenteams-v2is enabled, using a recursive CTE for subordinate IDs. - (2026-02-26) AvailabilitySettings now unions reports_to subordinates with team members when
teams-v2is enabled. - (2026-02-26) Added
getReportsToSubordinatesaction and updated SchedulePage to grant availability access for reports_to managers whenteams-v2is enabled. - (2026-02-26) Added migrations for team member roles:
server/migrations/20260226171000_add_role_to_team_members.cjsand backfill lead roles in20260226171500_seed_team_member_leads.cjs. - (2026-02-26) Added
ITeamMembertype withroleand updated team actions/model to return member roles and set lead role for managers. - (2026-02-26) Added migrations for
assigned_team_idon tickets and project_tasks:server/migrations/20260226172000_add_assigned_team_id_to_tickets.cjsand20260226172500_add_assigned_team_id_to_project_tasks.cjs. - (2026-02-26) Added
assigned_team_idto ITicket and IProjectTask interfaces. - (2026-02-26) Added
assignTeamToTicketandassignTeamToProjectTaskactions to set assigned_team_id, set lead as primary if needed, and expand team members into resources with roleteam_member. - (2026-02-26) Fixed plan test harness to resolve repo root via
__dirnameso file path assertions work regardless of working directory. - (2026-02-26) Added
UserAndTeamPickercomponent with grouped user/team sections for teams-v2 assignments. - (2026-02-26)
UserAndTeamPickersearch now filters both users and teams together. - (2026-02-26) Team options in
UserAndTeamPickernow show member count and lead name. - (2026-02-26) Added generic team icon rendering in
UserAndTeamPicker(distinct from user avatars). - (2026-02-26) Team selection in
UserAndTeamPickernow triggers ticket/task team assignment actions. - (2026-02-26) User selection flow in
UserAndTeamPickermatches existingUserPickerbehavior. - (2026-02-26) Ticket detail "Assigned To" field now swaps to
UserAndTeamPickerwhenteams-v2is enabled. - (2026-02-26) Project task detail "Assigned To" field now swaps to
UserAndTeamPickerunderteams-v2. - (2026-02-26) Preserved
UserPickerrendering whenteams-v2is disabled. - (2026-02-26) Added team badge chip to the ticket "Agent team" card with icon, name, and remove affordance.
- (2026-02-26) Team badge rendering is gated behind the
teams-v2feature flag. - (2026-02-26) Team badge remove button now opens a confirmation dialog.
- (2026-02-26) Remove-all option clears
assigned_team_idand deletesteam_memberticket resources. - (2026-02-26) Keep-all option clears only
assigned_team_id, preserving existing ticket resources. - (2026-02-26) Added selective team-member checkboxes in the removal dialog.
- (2026-02-26) Team removal actions preserve the primary
assigned_touser. - (2026-02-26) Team assignments are independent of individual agent add/remove flows.
- (2026-02-26) Team assignment resources are treated as a snapshot (no auto updates on roster changes).
- (2026-02-26) Ticket list "Assigned To" filter now includes teams when
teams-v2is enabled. - (2026-02-26) Team selections in the ticket list filter now map to
assigned_team_id. - (2026-02-26) Ticket list assignee filter reverts to user-only behavior when
teams-v2is disabled. - (2026-02-26)
tickets.createworkflow action now supports team assignee payloads and expands team members. - (2026-02-26) Tenant export runbooks annotated to confirm
reports_to,assigned_team_id, androleexport coverage. - (2026-02-26) Marked T002 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T003 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T004 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T005 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T006 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T007 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T008 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T009 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T010 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T011 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T012 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T013 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T014 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T015 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T016 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T017 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T018 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T019 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T020 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T021 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T022 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T023 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T024 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T025 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T026 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T027 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T028 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T029 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T030 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T031 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T032 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T033 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T034 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T035 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T036 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T037 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T038 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T039 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T040 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T041 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T042 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T043 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T044 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T045 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T046 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T047 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T048 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T049 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T050 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T051 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T052 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T053 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T054 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T055 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T056 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T057 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T058 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T059 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T060 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T061 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T062 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T063 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T064 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T065 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T066 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T067 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T068 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T069 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T070 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T071 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T072 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T073 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T074 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T075 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T076 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T077 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T078 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T079 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T080 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T081 test covered by teams-v2 plan suite.
- (2026-02-26) Marked T001 test covered by teams-v2 plan suite.