Skip to content

Fix opening origin prescription from custom-economy review - #627

Merged
marceloarocha merged 1 commit into
developfrom
claude/undefined-origin-error-b2j5jv
Sep 10, 2026
Merged

Fix opening origin prescription from custom-economy review#627
marceloarocha merged 1 commit into
developfrom
claude/undefined-origin-error-b2j5jv

Conversation

@marceloarocha

Copy link
Copy Markdown
Collaborator

Summary

Fixes a bug where the "Abrir prescrição" (Open prescription) button in the intervention outcome form would break when reviewing custom-economy interventions (economyType 3), which lack the "original" block in their outcome data.

Changes

  • InterventionOutcomeForm.jsx: Updated the conciliation flag lookup to gracefully handle missing original block by falling back to the current origin item's conciliation value

    • Changed from outcomeData?.original.origin?.item?.concilia to outcomeData?.original?.origin?.item?.concilia ?? outcomeData?.origin?.item?.concilia
    • Added explanatory comment about custom-economy interventions
  • multipleOutcome.spec.ts: Added test case to verify the "Abrir prescrição" button works correctly when opening a prescription from a custom-economy review

    • Mocks a custom-economy intervention without the "original" block
    • Verifies the button successfully opens the origin prescription in a new window

Implementation Details

Custom-economy interventions (economyType 3) return outcome data without the "original" block structure. The fix uses optional chaining and nullish coalescing to safely access the conciliation flag from either the original origin item (if available) or fall back to the current origin item, ensuring the prescription link button functions correctly in both scenarios.

https://claude.ai/code/session_01LvfyXg2gsDNj9ZKKeGrjP4

The "Abrir prescrição" button in the intervention outcome form read
`outcomeData?.original.origin?.item?.concilia`. The optional chain stops
at `outcomeData`, so `.original.origin` is a plain access — and
custom-economy interventions (economyType 3) come back from the backend
without the `original` block. The form still renders (the economy
calculators are skipped for that type), so the crash only happens on
click:

  TypeError: Cannot read properties of undefined (reading 'origin')

Read `original` optionally and fall back to the flag on the current
origin item, which carries the same `concilia`.

Adds a mocked e2e regression test that reaches the custom-economy review
step of the bulk outcome flow and opens the origin prescription.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvfyXg2gsDNj9ZKKeGrjP4

@amazon-q-developer amazon-q-developer 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.

This PR successfully resolves the bug where the "Abrir prescrição" button would break when reviewing custom-economy interventions (economyType 3). The implementation correctly uses the nullish coalescing operator to provide a fallback when the original block is missing, and includes appropriate test coverage for the fix.

The changes are minimal, focused, and maintain backward compatibility with existing intervention types while properly handling the edge case for custom-economy interventions.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@marceloarocha
marceloarocha merged commit 0a43dd8 into develop Sep 10, 2026
9 checks passed
@marceloarocha
marceloarocha deleted the claude/undefined-origin-error-b2j5jv branch September 10, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants