Client Care Dashboard: choose AND or OR when multiple add-on categories are selected

Objective

  • Let Client Care staff choose how multiple add-on global categories combine when more than one category is selected:
  • Match all (AND) — count only core orders that carry every selected category (via distinct services / charges as appropriate).
  • Match any (OR) — keep today’s union behavior: orders that carry at least one of the selected categories (current combined add-on semantics).
  • Default behavior - (OR)
  • Ensure combined add-on metrics and scheduler selectedAddOnRate (when categories are passed) follow the same mode so the dashboard never implies one rule while the API applies another.
  • Make the active rule obvious in the UI (copy next to the control and/or combined card) so numbers are not misread.

Background

  • Coordinators reported that with two categories selected (e.g. radon + termite), results looked like either category, not both — that matches current backend combined logic (union of service ids → ANY).
  • Internal thread: Message from ryan — Slack.
  • Original intake: "On the Client Care dashboard, the add-on selector appears to use OR logic instead of AND logic. For example, selecting radon and termite shows orders with either add-on instead of only orders that have both."
  • Decision needed: Default for users who never touch the control (and for existing saved views with no stored mode): treat as match any (OR) to preserve legacy numbers, vs default match all (AND) — product call.
  • Decision needed: When only one category is selected, hide the control vs show disabled with helper text — minor UX.

Scope

Frontend

  • attik-frontend/src/app/admin/client-care-dashboard/_components/AddonRatesPanel.tsx — add a clear control (e.g. segmented buttons or radio group): Match all / Match any, visible when two or more categories are selected (unless product prefers always visible).
  • attik-frontend/src/app/admin/client-care-dashboard/CCDashboardClient.tsx — pass the chosen mode on cc-dashboard/metrics and cc-dashboard/scheduler-metrics requests alongside globalCategoryIds (exact query key is Decision needed, e.g. globalCategoryMatch=all|any).
  • attik-frontend/src/app/admin/client-care-dashboard/view/[viewId]/page.tsx and SaveViewModal / save payload — persist mode on the saved view when Decision needed for schema field name.
  • attik-frontend/src/app/admin/client-care-dashboard/_types.ts — extend saved-view / client types for the new field.
  • attik-frontend/src/app/admin/client-care-dashboard/ClientCareViewsClient.tsx — optional: surface mode in the view list summary if saved per view.
  • Per-category addonRates cards today are inherently per category; Decision needed whether AND/OR only affects addonRatesCombined (and scheduler) or also changes how individual cards are interpreted.

Backend

  • attik-backend/src/routes/ccDashboard.ts — extend GET /cc-dashboard/metrics: honor mode when computing addonRatesCombined (and document in response types / file header comment). AND likely requires counting inspections that have at least one qualifying charge per selected category (intersection of distinct inspection id sets or equivalent aggregation), not a single flat $in over unioned service ids.
  • Same file — GET /cc-dashboard/scheduler-metrics: apply the same parameter to selectedAddOnRate / resolveAddonServiceIdsForCategories usage so scheduler totals agree with the dashboard.
  • attik-backend/src/models/ccDashboardViewSchema.ts and attik-backend/src/routes/ccDashboardSavedViews.ts — add optional persisted field for the mode; migration: missing field → default per product (see Background).
  • attik-backend/scripts/createCcDashboardViews.ts / cc_inspection_base — only touch if AND cannot be expressed efficiently in the route; otherwise keep view unchanged.

Product

  • Final labels for end users ("All selected add-ons" vs "Any selected add-on" or similar) and tooltip text explaining denominators (core orders).
  • Release note: saved views gain optional mode; default behavior for old views.

References

  • Message from ryan — Slack
  • attik-frontend/src/app/admin/client-care-dashboard/CCDashboardClient.tsx
  • attik-frontend/src/app/admin/client-care-dashboard/_components/AddonRatesPanel.tsx
  • attik-backend/src/routes/ccDashboard.ts
  • attik-backend/src/routes/ccDashboardSavedViews.ts
  • attik-backend/src/models/ccDashboardViewSchema.ts
  • attik-backend/scripts/createCcDashboardViews.ts

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board
🏠

Main App

Date

16 days ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.