Fix opening origin prescription from custom-economy review - #627
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
originalblock by falling back to the current origin item's conciliation valueoutcomeData?.original.origin?.item?.conciliatooutcomeData?.original?.origin?.item?.concilia ?? outcomeData?.origin?.item?.conciliamultipleOutcome.spec.ts: Added test case to verify the "Abrir prescrição" button works correctly when opening a prescription from a custom-economy review
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