# 2026-10-13 — code study of the 7 sales-flow pages, and the fixes

Two passes in one Claude Code session on `dev-shawn` (HEAD `dc7db4713`). **Nothing is committed**; every change is in the
working tree beside other sessions' work. Read the code before trusting this file.

## 1. What was studied

Every frontend and backend file behind:

| # | Page | Entry point |
|---|---|---|
| 1 | `/manage/my-work` — **Sales steps** (`tab=workflow`, default) | `MyWorkController@index` → `MyWorkResponsibilities` |
| 2 | `/manage/my-work?tab=tasks` — **Action Item** | `MyWorkBoard::tasks()` |
| 3 | `/manage/my-work/sales-flow?guide=live` | `MyWorkController@salesFlow` → `flowBoard` (Preview + Project + Closing boards) |
| 4 | `/manage/my-work/sales-flow?guide=flow` | static `salesFlowOperations.js` charts |
| 5–7 | `/manage/events/funnels/{uuid}?tab=journey&jstage=1/2/3` | `FunnelsController::journeyBoard()` → `PreviewJourneyBoard` / `ProjectJourneyBoard` |

plus the engine that feeds them (`FunnelJourney*`, hooks, scanner rules, hand-offs, `EnsureFunnelHumanContact`), the
Record-contact write path, and the per-lead bar / chart (`SalesFlowChartPath`). Nine read-only agents read the files in
full; their findings were then checked against the code before anything was changed.

## 2. What was fixed (5 fix agents + the coordinator)

Every bug fix has one regression test in the class's existing test file (CLAUDE.md test policy).

**My Workspace (Sales steps / Action Item)** — `MyWorkResponsibilities`, `MyWorkBoard`, `LeadActionItemRepository`,
`MyWorkController`, `Index.vue`, `ResponsibilitiesBoard.vue`
- Two paid deals of one customer on one Project were collapsed into one Sales-steps item (entry key had no deal).
- Tasks with no priority sorted before High (Action Item, nobody view, Sales steps).
- Conversation-automation tasks were labelled "Colleague" → "AI".
- The nobody view computed `outcome_url` per row (an Engagement query each) that no button used.
- A second Done (stale page) re-stamped `done_by` / `done_at` → the first close is kept, the journey hook runs once.
- AI-plan steps are left out of the lists while the Action Plans release control is OFF (they could not be closed).
- A colleague's agreed follow-up never became due on the account manager's board (`due_at` was null).
- Help team label said "N overdue" but also counted new customers → "N need help".
- A managed customer lost ALL its obligations when a colleague held the journey's hand-off (08 audit item 3): now only
  the obligation that colleague's open task covers is left out.
- Paused funnels (`is_active = false`) no longer produce Sales-steps work; the guide's default Project funnel is the
  first ACTIVE one.
- `?task=` of a task closed without a result landed on the wrong view (`stepOf()`).
- A task closed as **Cannot be reached** showed as "Check records" in To do → Done (owner meaning: it closes the contact).
- Help team kind 2 skipped new customers whose only Preview registration was on a cancelled Session / merged funnel.
- Action Item / Done / nobody view opened the lead PAGE → the lead quick-view modal (owner rule 2026-10-09).

**The live boards (backend)** — `PreviewJourneyBoard`, `ProjectJourneyBoard`, `ProjectJourneyContexts`,
`ClosingJourneyBoard`, `JourneyWorkQueue`, `LeadJourneyOverview`, `FunnelFollowUpState`, `FunnelsController`
- "Lead added from / to" filter was shifted 8 hours (`->utc()` against MYT `created_at`).
- An after-webinar hand-off of a no-show counted in the Stage 1 "Call needed" box → Stage 2 `no_show`.
- Closing roster printed a raw ISO timestamp as the due label.
- D6 Stage-1 checks are batched per roster page (`rememberStageOne()`).
- A Journey-tab reload (`only: ['journeyBoard']`) no longer runs the whole funnel page's queries (early return).
- A Project fee on a CANCELLED Session of the same funnel read as "paid through another funnel".
- NULL-currency receipts are grouped as MYR; the lead overview hides fees of Projects outside the viewer's group.
- A later "No answer" on another closing queue hid a recorded **Not closed** → the newest decision-bearing outcome wins.
- The paid Project item read "To do" with no button → Done, "In Stage 3".
- "Cannot be reached" recorded on a suggestion is a finished contact (Done) for the D3 window, not "Check the recorded
  result" in To do.
- Dead `ProjectJourneyContexts::attribution()` removed.

**Engine + Record contact (backend)** — `FunnelJourneyHooks`, `FunnelJourneyRepository`, `FunnelJourneyHandoff`,
`Rules/*`, `AdvanceFunnelJourneys`, `FunnelFollowUpController`, `FunnelFollowUpRepository`, `ThankYouController`,
`LandingController`
- Context path no longer flashes for AJAX (the button toasts; no double message).
- A Session-less invite record is not linked to the journey (it could move a `human_pending` journey to "Colleague
  called" while the real call task stayed open).
- A Project-less record now conflicts with an open task on ANY Project of the same Session / queue.
- Paid service steps: a second contact continues the open context-path task instead of piling up new ones.
- An answered AI call is handed off at once in the hook (closes the A25 gap when the lead pays before the next scanner
  tick), with reason `ai_completed` / `ai_no_info` by its answers.
- A welcome-opened journey (e.g. From Preview) now points at its Session (`context_event_id`); no automation starts.
- A Won / Lost journey follows a later change of the SAME deal (booking cancelled → Not closed). A deal revived to an open
  status reopens the journey where it was (owner decision #6, §5; the lead's bar / chart drops "Closing" again).
- A Zoom booking no longer logs a fake "Colleague recorded the outcome"; a second sales Zoom is recorded.
- A paid customer's re-registration no longer replaces their REP as journey owner.
- No REP task for a payment refunded before the next tick; "unpaid" never fires while the Zoom webinar is still live.
- Rules sleep once the contact is recorded (no endless 15-minute re-checks).
- The scanner skips paused funnels (they resume when switched back on).
- The task's verdict line reads its own Session's attendance.
- Wording after A25: "Not called before the webinar — task still open" (not "expired"); stale docblocks.
- Correcting the phone on the thank-you page no longer rings a visitor who unticked the AI call (the landing now stores
  `welcome_ctx.ai_call_opt_in` + `event_id`; 03 §E item).

**Live board, guide and Record-contact frontend** — `SalesJourneyWorkspace.vue`, `SalesFlowMap.vue`,
`salesFlowOperations.js`, `salesFlowGuide.js`, `Funnels/Show.vue`, `FunnelFollowUpButton.vue`,
`FunnelSessionRegistrationModal.vue`, `ActionItemsPanel.vue`, `EngagementProgressCell.vue`, `DataTable.vue`
- Record contact's task path posted without `X-Requested-With` → 302, lost toast, "already closed" looked like success.
  Both paths now post as XHR and toast the result; refusals stay in the form.
- Lead modal Done / Reopen / edit / delete swallowed refusals (same header).
- "Lead added to the session." toast was lost on the boards (`flash` added to the partial reload).
- Board load failures (500 / timeout) left the spinner forever → banner + Refresh.
- Back-button loop on entry without `jstage`; empty Stage 1 drawn when the server fell back to Stage 2; readiness counts
  never requested when the panel opened mid-load; an unknown `jowner` kept a fake "Selected owner"; a stage switch lost
  `?lead=`; FPA cells left the roster (now the modal); `#` restarted at 1 on page 2; the funnel header lagged its tab.
- "Open in My Workspace" from multi-step boxes opened All steps of every stage → the box's first step; the Invite box
  opens the Extra view. Stage 3 extra reads "Check records".
- Guide copy: From Preview DOES send the Session welcome; the button is "Record contact"; Messages link permissions;
  "Log the call" wording; WhatsApp replies are on Messages; Call questions are on the Slot page; Details view now opens a
  clicked box's help and My Workspace link.

**Per-lead bar / chart** (`SalesFlowChartPath`, `FunnelJourney::chipsForLeads()`, `SalesFlowProgress.vue`) — every
[05](05-review-findings-2026-10-07.md) finding: C1/C5 list vs page journey choice (one rule, list keys in the same
query), C2 Project last move, C3 band 2 record, C4 hover names the stage, U1–U4, merge reconcile. Design: funnel-journey
readMe §6d (new).

## 3. Tests run (final, all changes together, one test database)

- PHPUnit, 32 files (My Work, boards, follow-up, journey, chart path, AI-call automation, Preview candidates, reminders,
  workflow registration, reps, round robin, calendar, thank-you, payment AI call, action items, Revenue Journey
  workflows, Meta pixel): **322 tests, 2,501 assertions, OK** (1 pre-existing PHPUnit deprecation).
- vitest (MyWork, Funnels, Components/Leads, Leads partials, Components/Sales, DataTable): **54 files, 309 tests, OK**.
- `vendor/bin/pint --test` on every changed PHP file: passed. `php scripts/check-suite-links.php`: OK, ratchet 67/67.
- The fix agents used private databases `petav3_sf{a,b,c}_testing` with configs `phpunit.sf{a,b,c}.xml` (local only,
  listed in `.git/info/exclude`).

## 4. Visible behaviour changes for staff (tell the team)

- "Cannot be reached" now counts as a finished contact (Done) — it no longer sits in To do for 30 days.
- An answered AI call becomes a call task immediately (not up to 5 minutes later).
- A paused funnel stops creating hand-offs and Sales-steps work.
- Customer links on the Action Item tab open the quick-view modal.
- A booking cancelled after "Booked" turns the customer's journey to "Not closed".

No migration, no new config key, no new env var. Deploy needs nothing beyond the normal deploy.

## 5. Not changed — questions for the owner

1. **Swing** deals count under the Project board's "Not closed" box (the Closing board treats Swing as not a loss). Keep?
2. A deal **Booked without a Project-fee receipt** is never counted as Won on the boards. Count it?
3. **A3 (open since 10-06):** may leaders reassign ANY task, incl. a colleague's recorded contact task (`canEditFor`)?
   → **Decided 2026-10-13: yes (assignees only) — built, see below.**
4. The **Action Item** tab badge counts every open task (incl. future-dated); Sales steps counts only To do. Same rule?
5. Legacy tasks closed by the system before A25 still show "Check the old task" in To do.
6. A deal **revived** after Booked / Not closed leaves the journey closed. → **Decided 2026-10-13: reopen — built, see below.**
7. A REP who closes the "book the Zoom" task without booking leaves the journey at "Closer assigned" (the Closing board
   still lists the step).
8. `EnsureFunnelHumanContact` does not notice an EARLIER deadline (Session moved earlier). → **Decided 2026-10-13: re-queue
   — built, see below.**
9. The guide's links to CEO pages switch the sidebar to Operations (GUIDELINES §15 forbids hard-coded suite tokens; needs
   a design decision). Reset on the live board keeps the chosen Project funnel. Unknown `jnode` lists everyone.
10. Service-step continuation (C4) cannot replay a lost response with the same `submission_uuid` (would need a new
    `handoff_context` key through `LeadActionItemRepository::update`).

Slot configuration gaps from [08](08-workflow-readiness-audit-2026-10-08.md) (no Bridge groups, no after-webinar rules, no
Project offers on Stage 2 Slots, literal dates in reminders) are data, not code — unchanged.

**Owner decisions 2026-10-13 — #3, #6, #8 (agent G, built; uncommitted):**
- **#3 All sales may reassign anybody's task.** A super admin or `view-leads-all` holder (My Workspace's `canPick`)
  may change the **assignees** of any task on a lead they can see — `LeadActionItem::canReassignFor()` /
  `reassignsAnyTask()`. `ActionItemsController@update` writes only the assignees for such a viewer (body, type,
  priority, due date, attachments ignored); payload `can_reassign`; the lead's Action items panel shows a **Reassign**
  button (`ActionItemEditor` `assignOnly`); the nobody view's `can_assign` follows the same rule (every row's
  "Assign on the lead" now works). Edit stays author-only, delete author / super admin. Test:
  `ActionItemNotifyTest::test_a_leader_reassigns_a_colleagues_task_without_rewriting_it`.
- **#6 A revived deal reopens its journey.** The deal that made a journey's last close moving to an open status (not
  Booked / Following Up / Converted / Lost / Swing) records `deal_reopened` ("Deal back in progress — journey
  reopened"): back to the close's `from_step` with the stage it had then, ACTIVE, `closed_at` / `lost_reason_code`
  cleared; no new registration cycle. Booking it again closes the journey again. The brief's example "Lost →
  Following up" was NOT treated as open: Following Up is the retired post-booking status every board counts as a win.
  Test: `FunnelJourneyTest::test_a_revived_deal_reopens_its_journey_where_it_was` (Lost → With Closer → Booked).
- **#8 An earlier webinar time makes the contact deadline earlier.** `EventRepository::update` passes the old start to
  `FunnelJourneyHooks::sessionChanged()`; a start moved EARLIER re-queues `EnsureFunnelHumanContact` for the Session's
  landing registrations still registered and not muted, at the new `dueAt()` (now when due), chunked by 200. A later
  start needs nothing (the waiting job re-dispatches itself). Test:
  `FunnelJourneyTest::test_a_session_moved_earlier_requeues_the_contact_at_the_earlier_deadline`.

**Owner decisions 2026-10-13 — #1, #2, #10, #11 (agent F, built; uncommitted)** — #10 and #11 are the last two
sentences of item 9 above:
- **#1 Swing is not "Not closed".** `ProjectJourneyContexts::resolve()`: a context whose own deals all ended with a
  Swing is the new Project node **`swung`** ("Moved to another project"), drawn as the Stage 3 extra chip
  `project:swung` ("Unpaid · moved to another project") beside `closing:swung` (now "Paid · moved to another
  project"). A Lost deal, a recorded Not closed or a stopped / lost journey stays `lost`. Roster item: done, badged
  "Moved to another project". My Workspace → Sales steps: a Done item *Moved to another project*
  (`MyWorkResponsibilities::projectEntries()`), never *Not closed*. Test:
  `ProjectJourneyBoardTest::test_a_swing_is_moved_to_another_project_never_not_closed`.
- **#2 Booked without a Project fee is Won.** A deal Booked / Following Up / Converted with no Project fee for its
  Project is the new Project node **`won`** ("Booked · no Project fee"; was `review`), a chip in Stage 3's **Won** box
  beside `closing:booked` / `closing:converted`. A context with the fee stays `paid` (a fee paid through another funnel
  stays `review`), so only the Closing board counts paid deals. Roster item done, badged "Won"; no My Workspace step
  (none existed). Test: `ProjectJourneyBoardTest::test_a_deal_booked_without_a_project_fee_is_won_and_a_paid_one_stays_paid`.
- **#10 Reset clears the Project funnel.** `SalesJourneyWorkspace.vue` `reset()` clears every filter, `jproject` too
  (no test: no vitest covers Reset).
- **#11 Unknown `jnode` → counts only** on `PreviewJourneyBoard`, `ProjectJourneyBoard` and `ClosingJourneyBoard`
  (`roster` / `work` / `readiness` null); `jnode=all` still lists everyone. Test:
  `ClosingJourneyBoardTest::test_an_unknown_count_returns_counts_only_on_every_board_and_all_still_lists_everyone`.
- Handbooks: sales-flow-chart (readMe, closing), funnel-journey readMe (Stage 1 / Stage 2 board sections), my-work.

## 6. Stale statements corrected in this folder

00 (feature table rows, 05 status), 01 (05 status), 02 (D6–D11 rows, A20 / A21 notes), 03 (header, A1, A9, §D, §E
ThankYou, §H.5–6), 04 (05 status), 05 (each finding marked fixed), 06 (banner listing every stale statement: useful AI →
no task, Log the call, Not called in time closes the task, From Preview opens a Project journey, questions per funnel),
08 (status of the human-responsibility findings), 09 ("nothing committed", "boxes open the whole stage", P3). Handbooks
updated in the same change: my-work, sales-flow-chart (readMe, closing, record-contact), journey-work, funnel-journey
(readMe incl. new §6d, readiness), events/funnels.
