Skip to content

MPDX-9327 - Add error handling to duplicate request mutation in CurrentBoardApproved#1648

Open
zweatshirt wants to merge 6 commits intomainfrom
MPDX-9327
Open

MPDX-9327 - Add error handling to duplicate request mutation in CurrentBoardApproved#1648
zweatshirt wants to merge 6 commits intomainfrom
MPDX-9327

Conversation

@zweatshirt
Copy link
Contributor

@zweatshirt zweatshirt commented Mar 16, 2026

Description

This prevents an unhandled runtime error and leads to better UI behavior for users.
Issue:

  • If a new request is open (a user has a request that they are editing but have not submitted), and they go back to edit their already submitted request via Update Current MHA, a runtime error occurs.
    Solution:
  • Handle the error gracefully by using Apollo's onError callback. Apollo provides a Snackbar for the error in client.ts

Error:

Error: You already have an open request. Please complete or delete it before duplicating this MHA request.

Future considerations: Possibly refactor to avoid the use of onCompleted and onError altogether.

Jira ticket

Testing

  • Go to reports/housingAllowance
  • Create a new request and edit it. Do not submit it.
  • Go back to the Housing Allowance dashboard.
  • Select 'Update Current MHA'
  • Ensure that the snackbar is shown and the error is properly handled.

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels (Add the label "Preview" to automatically create a preview environment)
  • I have run the Claude Code /pr-review command locally and fixed any relevant suggestions
  • I have requested a review from another person on the project
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

@zweatshirt zweatshirt self-assigned this Mar 16, 2026
@github-actions
Copy link
Contributor

Bundle sizes [mpdx-react]

Compared against 9e37831

No significant changes found

@zweatshirt zweatshirt requested a review from dr-bizz March 16, 2026 19:20
@zweatshirt
Copy link
Contributor Author

@dr-bizz The test I've added here is arguably unneeded (since I can't fully replicate the backend behavior for this test). That being said, I think the refactors to the tests are helpful.

@zweatshirt zweatshirt changed the title Add error handling to duplicate request mutation in CurrentBoardApproved MPDX-9327 - Add error handling to duplicate request mutation in CurrentBoardApproved Mar 16, 2026
Comment on lines +71 to +72
// Prevents unhandled promise rejection
onError: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

I would agrue that this is bad, we want an error to show when something like this happens. instead we should fix the core issue at hand, why do we allow the button to duplicate a MHA appear when they have one open

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point and I definitely agree, I can just hide the button altogether here. I'm not sure the reason we allow it to render, but if I had to guess it may have to do with the Figma design. I'll change that quickly.

Copy link
Contributor Author

@zweatshirt zweatshirt Mar 18, 2026

Choose a reason for hiding this comment

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

I wanted to be sure on this point: 'we want an error to show when something like this happens' you mentioned. An error does show if the onError callback is empty since client.ts provides a Snackbar for GraphQL errors. Working on ensuring the button is hidden now.

@zweatshirt
Copy link
Contributor Author

zweatshirt commented Mar 17, 2026

@dr-bizz Do you happen to know where availableDate is supposed to be coming from? When I approve requests in the MPDX stage DB like request.board_approve!, available_date is never set, returns as null in the UI response, and then the Current Board Approved card can never render. This is a related issue but not directly tied to this PR.

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