Skip to content

MPDX-10409 Let new staff dismiss the MPD goal ready card - #2322

Merged
jeff-clay merged 2 commits into
mainfrom
MPDX-10409-goal-ready-card-dismiss-key
Nov 30, 2026
Merged

jeff-clay merged 2 commits into
mainfrom
MPDX-10409-goal-ready-card-dismiss-key

Conversation

@jeff-clay

@jeff-clay jeff-clay commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Links

Description

New staff got a red "Validation failed: Key is invalid" error when they clicked View my MPD goal on the "Your MPD goal is ready" dashboard card. The goal page still opened, but the error toast showed on top of it, and the card came back on the next dashboard visit. The X on the card runs the same save (both buttons call acknowledge()), so it failed the same way. This happens in production too.

Both buttons save a user option named new_staff_goal_acknowledged_<goal id>. Goal ids are UUIDs, so the name has hyphens. The API only accepts letters, numbers and underscores in option keys (User::Option validates /\A[A-Za-z0-9_]*\z/), so every save failed.

  • The card now builds the key with every character the API does not accept turned into _ (for example new_staff_goal_acknowledged_01a22dd6_f909_7f70_...). The same key drives both the read (useUserOptionQuery) and the save, so they always match.
  • No fallback for the old key shape: a key with hyphens could never be saved, so no one has a value stored under it.
  • No API change.

Testing

Jest (NewStaffGoalReadyCard.test.tsx, 13 tests):

  • The test goal id now has several hyphens, like a real UUID (a1b2c3d4-e5f6-4a7b-8c9d-0e1f). The tests expect the literal key new_staff_goal_acknowledged_a1b2c3d4_e5f6_4a7b_8c9d_0e1f, which fits the API's format.
  • The mocked UserOption query now answers the stored figures only for that exact key, so the read side is pinned too, not just the save.
  • Without the fix, 5 tests fail (the save tests and the "stays hidden" / "comes back updated" read tests). They also fail if the replace loses its g flag and only swaps the first hyphen. With the fix, all 13 pass.

Local QA (local API and frontend, local dev data only): a new-staff user with a sent goal whose id is a UUID.

  • Before (origin/main code): clicking X (the same save as "View my MPD goal") showed the red "Validation failed: Key is invalid" toast. The API answered createOrUpdateUserOption: null with key: ["is invalid"], and the card was back after a reload.
  • After (this branch): clicking X saved new_staff_goal_acknowledged_01a22dd6_f909_7f70_9f9a_956a609fd3b3 with no error, and the card stayed away after a reload.
  • After, goal changed: I raised the test goal's salary. On reload the card came back as "Your MPD goal was updated". "View my MPD goal" saved with no error and opened the New Staff Goal Calculator. Back on the dashboard, the card stayed hidden.
  • A "403: Forbidden" toast showed on both main and the branch in local QA only. It comes from the dashboard's weekly coaching answer-set call on my local list (the list's salary organization is not one of its users' organization accounts) and is not related. It did not show on staging.

Before and after screenshots are in a PR comment.

To check on staging, impersonate a new-staff user whose goal has been sent:

  • On the dashboard, click View my MPD goal on "Your MPD goal is ready". The goal page should open with no "Key is invalid" toast.
  • Go back to the dashboard and reload. The card should stay gone.
  • The X runs the same save, so it should also close the card with no error.

AI review

Findings I did not fix, and why:

Round 1 (/agent-review:review, /code-review xhigh plus the security, testing, standards and ux lanes; not posted): no blockers, 5 suggestions from /code-review, none from the other lanes. Fixed in 9acdf98:

  • Severity 5: the test goal id goal-1 had one hyphen, so a replace without the g flag would still pass. The tests now use an id with four hyphens.

Round 2 (posted, head 9acdf98, same engine and lanes): no blockers, 4 suggestions, all from /code-review. The github-actions bot approved 9acdf98. Left as is:

  • #1 (4/10, deferred): a shared helper for building option keys near useUserPreference. This card is the only place that builds a key from an id today, so one inline line is enough for now.
  • #2 (3/10, pre-existing): Dashboard.test.tsx uses goal id goal-1 with a catch-all UserOption mock. This PR does not touch that file, and the card's own tests pin the exact key.
  • #3 (3/10, intentional): turning every rejected character into _ could map two ids to one key. Goal ids are UUIDs, whose only rejected character is -, so two UUIDs can never collide.
  • #4 (2/10, intentional): the test id is not a full UUID (its last group is short). It keeps the expected key on one line so the test file stays under CodeScene's 300-line test limit, and its four hyphens still catch a replace without the g flag.

Checklist:

  • My PR title is the work item key, then a summary of 80 characters or less (example: MPDX-1234 Add sortable columns)
  • I have applied the appropriate labels (Add the label "Preview Environment" to automatically create a preview environment)
  • I have run the Claude Code /agent-review:review command locally and fixed each finding or listed it above
  • The github-actions bot has approved the PR (it approves once /agent-review:review leaves no open blockers; it never approves a one-way door)
  • I have asked a person to review, if this is a one-way door (it touches a path .github/CODEOWNERS gives an owner)
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

🤖 Generated with Claude Code

Staging QA

11/30/2026 on stage.mpdx.org (build l0fYcm4sJ_Ovap8XpiJsh, after this PR landed on staging), impersonating the Pedra Pérez test user (temporarily New Staff) on a household whose goal was Run & Sent:

  • The "Your MPD goal is ready" card shows.
  • Clicking X dismisses it with no "Key is invalid" error.
  • After a reload the card stays dismissed.

Result: PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeff-clay jeff-clay self-assigned this Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle sizes [mpdx-react]

Compared against aadea9a

No significant changes found

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeff-clay

Copy link
Copy Markdown
Contributor Author

🤖 agent-review · ✅ no blockers · risk LOW
Rollout: advisory · 5 agents run (Code Review (/code-review xhigh), Security Review Agent, Testing & Quality Review Agent, Standards Compliance Review Agent, UX & Accessibility Review Agent)

BLOCKERS: fix or dismiss to pass

✅ No blockers.

OTHER FINDINGS (4)

  • #1 · 4/10 · src/components/Dashboard/NewStaffGoalReadyCard/NewStaffGoalReadyCard.tsx:100 · The option key cleanup lives inline in one component, so the next caller that builds a key from an id can hit the same API rejection. (code-review)
  • #2 · 3/10 · src/components/Dashboard/Dashboard.test.tsx:170 · The Dashboard integration test uses goal id 'goal-1' and a catch-all UserOption mock, so it never checks the sanitized key. (code-review)
  • #3 · 3/10 · src/components/Dashboard/NewStaffGoalReadyCard/NewStaffGoalReadyCard.tsx:100 · Mapping every rejected character to '_' is lossy, so two ids that differ only in those characters would share one acknowledgement key. (code-review)
  • #4 · 2/10 · src/components/Dashboard/NewStaffGoalReadyCard/NewStaffGoalReadyCard.test.tsx:26 · The test goal id is not UUID-shaped (last group has 4 hex digits, not 12), though it still exercises the global hyphen replace. (code-review)
🔧 Fix suggestions (0)

No automated fixes for this review.

📦 Dependency impact

Blast radius: 4 files. NewStaffGoalReadyCard.tsx is imported by src/components/Dashboard/Dashboard.tsx, which reaches src/components/Dashboard/index.tsx, pages/accountLists/[accountListId].page.tsx and src/components/Dashboard/Dashboard.test.tsx.

File Dependents
src/components/Dashboard/NewStaffGoalReadyCard/NewStaffGoalReadyCard.tsx 1
src/components/Dashboard/NewStaffGoalReadyCard/NewStaffGoalReadyCard.test.tsx 0
📊 Review detail & stats

Generated: 2026-11-30 · Day: Monday · Files changed: 2 (+6 -5 lines)
Risk score: 2 · LOW · Required reviewer: entry

Risk factors detected: none

Deterministic evidence:

  • AST/static rules: none
  • CI snapshot: not collected in this local run
  • Cross-repo context: none

Agent summary (bands: Critical 9-10 · High 7-8 · Important 5-6 · Suggestions 3-4):

Agent Critical High Important Suggestions Confidence
Code Review (/code-review xhigh) 0 0 0 3 H
Security Review Agent 0 0 0 0 H
Testing & Quality Review Agent 0 0 0 0 H
Standards Compliance Review Agent 0 0 0 0 H
UX & Accessibility Review Agent 0 0 0 0 H
Total 0 0 0 3 -

Finding #4 (2/10) is below the Suggestions band.

Per-agent perspectives on blockers: none.

Engine: code-review (from config) · effort xhigh (from config) · model opus (from config)
/code-review findings: found 4 · scored 4 · dropped 0

Review quality:

  • Average agent confidence: High · Consensus rate: n/a (no overlapping findings) · Review time: about 6 minutes
  • Findings suppressed by approved learnings: 0
💬 How to act on this review

Every finding above is numbered. Severity ≥ 7 findings carry a checkbox and must each be fixed or
dismissed
before this review counts as passed; lower severities are advisory. This repo runs
reviews locally only, so work this ledger with /agent-review:address in a Claude Code session.
It fixes or dismisses findings (a reason code and explanation are required for a dismissal) and
keeps this comment in sync. Valid codes: false-positive, intentional, pre-existing,
deferred, duplicate, insufficient-evidence, other.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: the agent-review report for this head passes with no open blockers, and no repo rule or recorded check needs a person.

@jeff-clay jeff-clay added the On Staging Will be merged to the staging branch by Github Actions label Nov 30, 2026
@jeff-clay

jeff-clay commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Before and after: "View my MPD goal" on the "Your MPD goal is ready" card

Both buttons on the card ("View my MPD goal" and the X) run the same save. Before this fix that save always failed, because the option key had the goal id's hyphens in it.

Before (staging, before this fix): click "View my MPD goal" After (staging, this PR): click "View my MPD goal"
Before: goal page opens with a Validation failed: Key is invalid toast After: goal page opens with no error toast
The goal page opens, but a red "Validation failed: Key is invalid" toast shows (bottom left). The save failed, so the card comes back on the next visit. The goal page opens with no toast.

After, the full path on staging (test new-staff user whose goal was sent):

  1. The card shows on the dashboard.
After: Your MPD goal is ready card with the View my MPD goal button
  1. Click "View my MPD goal": the goal page opens with no toast (the right-hand shot above).

  2. Back on the dashboard, after a reload: the card stays gone.

After: dashboard after reload, card no longer shown

The X runs the same save. Locally on this branch it closed the card with no error, and the card stayed gone after a reload.

No real names: the top bar and greeting are cut out, and in the before shot everything below the Monthly Needs header is blanked except the toast.

@jeff-clay
jeff-clay merged commit c8a4738 into main Nov 30, 2026
62 of 64 checks passed
@jeff-clay
jeff-clay deleted the MPDX-10409-goal-ready-card-dismiss-key branch November 30, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

On Staging Will be merged to the staging branch by Github Actions two-way-door

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant