Skip to content

Conversation

@zweatshirt
Copy link
Contributor

@zweatshirt zweatshirt commented Dec 11, 2025

Description

Determines MHA eligibility based on grahpql data.
Related API PR: https://github.com/CruGlobal/mpdx_api/pull/3090

Testing

  • Go to reports/housingAllowance
  • Test that the MHA EIT value is correctly pulled from the mock service on the backend
  • Check that the conditionals work as expected in the UI.
  • You may need to remove the current request that's set in the UI to check the New Request functionality.

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 Dec 11, 2025
@zweatshirt zweatshirt added the Preview Environment Add this label to create an Amplify Preview label Dec 11, 2025
@github-actions
Copy link
Contributor

Preview branch generated at https://MPDX-9129.d3dytjb8adxkk5.amplifyapp.com

@zweatshirt zweatshirt added the Staging API Run GraphQL codegen against the staging API label Dec 11, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Bundle sizes [mpdx-react]

Compared against cfa6ff2

No significant changes found

@zweatshirt zweatshirt changed the title MPDX-9129 - MHA Eligibility check MPDX-9129 - MHA Eligibility check for new requests Dec 11, 2025
@kegrimes kegrimes mentioned this pull request Jan 8, 2026
6 tasks
@zweatshirt zweatshirt removed the Staging API Run GraphQL codegen against the staging API label Jan 12, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements MHA (Minister Housing Allowance) eligibility checking based on GraphQL data from the backend. The feature adds a new mhaEit field with mhaEligibility boolean to HCM data and enforces eligibility checks when users attempt to create or update MHA requests.

Changes:

  • Added mhaEit.mhaEligibility field to GraphQL schema and mock data
  • Implemented eligibility state management in the context provider
  • Added eligibility checks to all MHA request mutations with user feedback via snackbar notifications
  • Updated display logic to show appropriate messages for ineligible users and spouses

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/components/Reports/Shared/HcmData/HCMData.graphql Added mhaEit field with mhaEligibility boolean to GraphQL query
src/components/Reports/Shared/HcmData/mockData.ts Added mock data for various eligibility scenarios (single/married, eligible/ineligible combinations)
src/components/Reports/MinisterHousingAllowance/Shared/Context/MinisterHousingAllowanceContext.tsx Added userEligibleForMHA, spouseEligibleForMHA, hcmLoading, and hcmError to context
src/components/Reports/MinisterHousingAllowance/MinisterHousingAllowance.tsx Added eligibility check to new request creation with canAccessMHA logic
src/components/Reports/MinisterHousingAllowance/MainPages/IneligibleDisplay.tsx Updated to show conditional messages based on user and spouse eligibility status
src/components/Reports/MinisterHousingAllowance/Steps/StepTwo/RentOwn.tsx Added eligibility check to block updates when user is ineligible
src/components/Reports/MinisterHousingAllowance/Steps/StepThree/Calculation.tsx Added eligibility check to updateCheckbox function
src/components/Reports/MinisterHousingAllowance/Shared/AutoSave/useSaveField.ts Added eligibility check to saveField callback
Multiple test files Added SnackbarProvider wrapper and test cases for eligibility scenarios

Once approved, when you calculate your salary, you will see
the approved amount that can be applied to {preferredName}
's salary. If you believe this is incorrect, please
contact Personnel Records at 407-826-2236 or{' '}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The phone number in this error message (407-826-2236) differs from the phone number used in the earlier message on line 28 (407-826-2252). This inconsistency could confuse users. Verify which phone number is correct for Personnel Records and ensure it's used consistently throughout the component.

Suggested change
contact Personnel Records at 407-826-2236 or{' '}
contact Personnel Records at 407-826-2252 or{' '}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@zweatshirt zweatshirt Jan 12, 2026

Choose a reason for hiding this comment

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

Already reached out to Ryan to find out what the correct number is. Awaiting a response.

Comment on lines +50 to +63
{!hcmLoading &&
((isMarried && !spouseEligibleForMHA) || !userEligibleForMHA) && (
<Box mt={2} data-testid="user-ineligible-message">
<Trans i18nKey="userNotEligibleMha" values={{ preferredName }}>
<p style={{ lineHeight: 1.5 }}>
Once approved, when you calculate your salary, you will see
the approved amount that can be applied to {preferredName}
&apos;s salary. If you believe this is incorrect, please
contact Personnel Records at 407-826-2236 or{' '}
<a href="mailto:MHA@cru.org">MHA@cru.org</a>.
</p>
</Trans>
</Box>
)}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The condition for displaying the user-ineligible-message has a logic issue. The current condition ((isMarried && !spouseEligibleForMHA) || !userEligibleForMHA) will show the user-ineligible message even when the user IS eligible if they're married and the spouse is ineligible. This doesn't match the intended behavior based on the test cases and the message content.

The condition should be checking if the user is NOT eligible, or if both are married and both are ineligible. Consider simplifying to just !userEligibleForMHA since this message is specifically about the user's eligibility status and when they can see approved amounts.

Suggested change
{!hcmLoading &&
((isMarried && !spouseEligibleForMHA) || !userEligibleForMHA) && (
<Box mt={2} data-testid="user-ineligible-message">
<Trans i18nKey="userNotEligibleMha" values={{ preferredName }}>
<p style={{ lineHeight: 1.5 }}>
Once approved, when you calculate your salary, you will see
the approved amount that can be applied to {preferredName}
&apos;s salary. If you believe this is incorrect, please
contact Personnel Records at 407-826-2236 or{' '}
<a href="mailto:MHA@cru.org">MHA@cru.org</a>.
</p>
</Trans>
</Box>
)}
{!hcmLoading && !userEligibleForMHA && (
<Box mt={2} data-testid="user-ineligible-message">
<Trans i18nKey="userNotEligibleMha" values={{ preferredName }}>
<p style={{ lineHeight: 1.5 }}>
Once approved, when you calculate your salary, you will see
the approved amount that can be applied to {preferredName}
&apos;s salary. If you believe this is incorrect, please
contact Personnel Records at 407-826-2236 or{' '}
<a href="mailto:MHA@cru.org">MHA@cru.org</a>.
</p>
</Trans>
</Box>
)}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keeping this as is to match the criteria of the Figma doc. Can change if needed.

@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@CruGlobal CruGlobal deleted a comment from Copilot AI Jan 12, 2026
@zweatshirt zweatshirt marked this pull request as ready for review January 12, 2026 21:30
@zweatshirt zweatshirt requested a review from kegrimes January 12, 2026 21:31
@zweatshirt
Copy link
Contributor Author

zweatshirt commented Jan 12, 2026

@kegrimes You know MHA far more than I do. Before I ask Bizz for a review would you be up for looking through this quickly in case I missed something? Thanks Katelyn!

I am mostly looking to know if I have applied if statements to all MHA mutations, and if the state for IneligibleDisplay.tsx is correct.

I haven't actually been able to test this PR properly yet since we need to test an ineligible user.

@zweatshirt zweatshirt requested a review from dr-bizz January 15, 2026 14:28
@zweatshirt
Copy link
Contributor Author

@dr-bizz I was going to ask Katelyn to review this since she knows MHA well but since she's sick I've added you. We can get her review when she comes back.

Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

This is looking good. I think we might need to add some functionality that works out who the MHA is for, the user or the spouse, but apart from that, it's looking great.

Comment on lines +164 to +166
const userEligibleForMHA = useMemo(
() => userHcmData?.mhaEit?.mhaEligibility ?? false,
[userHcmData],
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should default to true while HCM is loading? So if HCM takes a while to load, it doesn't tell the user they can't create a MHA and then says it can.

This may be my preference, but I would prefer it to tell the user they can create an MHA, then tell them they can't, as this will affect less users.

spouseEligibleForMHA,
} = useMinisterHousingAllowance();

const canAccessMHA = userEligibleForMHA || spouseEligibleForMHA;
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought they would have to switch screens to be a ble to see if their spouse is eligible?

What. if the primary user is not Eligible but the spouse is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dr-bizz I asked Katelyn about this and neither of us are sure what the intended behavior there is. I assumed that the form should only apply to the user if eligible, or both if both eligible. If it's true the form can still be filled out for the spouse when the user is ineligible, I'll change that.

I'll reach out to Ryan as well to get better understanding.

Copy link
Contributor

Choose a reason for hiding this comment

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

Refer to comment in IneligibleDisplay! I already heard from Ryan.

Comment on lines +136 to 137
{hasNoRequests || !canAccessMHA ? (
<IneligibleDisplay />
Copy link
Contributor

Choose a reason for hiding this comment

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

This code reads as if they have no requests they get the same message as users who are not eligilble for MHA

} = useMinisterHousingAllowance();

const updateRequest = (id: string, rentOrOwn: MhaRentOrOwnEnum) => {
if (!userEligibleForMHA) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if they are filling it out for their spouse?


const updateCheckbox = (value: boolean) =>
const updateCheckbox = (value: boolean) => {
if (!userEligibleForMHA) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Again here, what if the user is filling the MHA out for their spouse whi is eligible?

if (!requestData?.id) {
return;
}
if (!userEligibleForMHA) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to work out who the MHA is for before saying the user is eligible

Comment on lines +32 to +35
{!hcmLoading &&
isMarried &&
userEligibleForMHA &&
!spouseEligibleForMHA && (
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the user is not eligible, but the spouse is?

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked with Ryan and he said to display the same text that you would for a person who is eligible and has a spouse who is ineligible. The only difference would be flipping the names around! He is thinking that the request would be created for the person who is eligible.

Copy link
Contributor

@kegrimes kegrimes left a comment

Choose a reason for hiding this comment

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

This looks great Zach, thank you for doing this! I had a few comments, but overall this looks good. Ryan got back to me with the missing case (user ineligible, spouse eligible) so hopefully you can implement that easily!

Comment on lines +32 to +35
{!hcmLoading &&
isMarried &&
userEligibleForMHA &&
!spouseEligibleForMHA && (
Copy link
Contributor

Choose a reason for hiding this comment

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

I checked with Ryan and he said to display the same text that you would for a person who is eligible and has a spouse who is ineligible. The only difference would be flipping the names around! He is thinking that the request would be created for the person who is eligible.

Comment on lines +50 to +51
{!hcmLoading &&
((isMarried && !spouseEligibleForMHA) || !userEligibleForMHA) && (
Copy link
Contributor

Choose a reason for hiding this comment

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

These checks feel like a lot in one place. Would we be able to extract these checks into a single variable instead? Even then, !hcmLoading and isMarried can possibly be it's own variable too.

const showSpouseIneligibleText = !hcmLoading && isMarried && userEligibleForMHA && !spouseEligibleForMHA

spouseEligibleForMHA,
} = useMinisterHousingAllowance();

const canAccessMHA = userEligibleForMHA || spouseEligibleForMHA;
Copy link
Contributor

Choose a reason for hiding this comment

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

Refer to comment in IneligibleDisplay! I already heard from Ryan.

Comment on lines +63 to +65
if (!userEligibleForMHA) {
enqueueSnackbar(t('You are not eligible to create a new MHA request.'), {
variant: 'error',
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing I noticed in MHA is that a lot of the backend logic already had errors set up, so I was getting a double snackbar sometimes. I'm not sure if you did that in the backend, but if not, this is great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would probably want some form of frontend validation to avoid making uneccessary requests. Maybe it's best to disable fields if they are ineligible instead, but I'm wondering what the best way to notify the user of their ineligibility might be (assuming they manage to get this far)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think with eligibility, it would be best to disable "New Request" button and maybe have an information alert box on the main page. This is what Ryan and I did with edit access and the new component I created was a safety net incase a user saved the edit page but their access changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I plan to do that, but a user can technically bypass that right? I don't know enough about MHA. I assume disabling the fields will be sufficient in this case.

if (!requestData?.id) {
return;
}
if (!userEligibleForMHA) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if this logic will ever execute since #1539 adds two new components: no edit access and no request access. If a user does not have edit access (status is not in_progress or action_required), they will get a blank page explaining that. If a user is not eligible for mha, they will get a blank page explaining that as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I rebase onto that branch?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could, I just might have some changes on that branch since it has not been reviewed yet!


const updateCheckbox = (value: boolean) =>
const updateCheckbox = (value: boolean) => {
if (!userEligibleForMHA) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, I don't think this logic will ever execute since they won't have access to this component.

} = useMinisterHousingAllowance();

const updateRequest = (id: string, rentOrOwn: MhaRentOrOwnEnum) => {
if (!userEligibleForMHA) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants