Repository navigation
MPDX-10092 Check staffAccountId before showing the PGA balance card - #2129
Merged
Merged
Conversation
Partner Giving Analysis is open to every user, and it decided whether to show the balance card by running the StaffAccount query. That query asks SAA for a full, unfiltered account summary, one of SAA's most expensive calls, on every page load, just to read the id. The card then runs its own FundBalances summary anyway. The report now uses the existing StaffAccountId query (user.staffAccountId, a plain MPDX read) to decide. BalanceCard now renders nothing when FundBalances fails. Before, it showed its skeleton forever on an error. That case used to be hidden because the StaffAccount query failed first for a user whose staff account SAA does not know. Now such a user passes the id check, so the card has to handle the failure itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Bundle sizes [mpdx-react]Compared against 8cef3e7 No significant changes found |
- With no Primary fund in a successful FundBalances answer, the card kept
its skeleton up forever. It now renders nothing once loading ends, the
same as on an error.
- donationPeriodTotalSum is Int!, so `{donationPeriodTotalSum && ...}`
printed a bare "0" and hid the total for a period with no gifts. The
total now shows $0.00.
- The report test comment states the rule (showing the card must not call
SAA) instead of describing the old code, and the card tests type their
GqlMockedProvider with the ApolloErgonoMockMap override pattern.
Found in a local /code-review pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dr-bizz
approved these changes
Oct 8, 2026
dr-bizz
left a comment
Contributor
There was a problem hiding this comment.
I'm so glad you found this and are fixing it. I don't think the person who added it knew that it would cost SAA as much as it did.
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.
Description
StaffAccountquery. For a user with a staff account id, the API answers that with a full, unfiltered SAA account summary (one of SAA's most expensive calls) on every page load, only to read the id. (Users without one never reached SAA; the resolver returns nil first.) The card then runs its ownFundBalancessummary anyway.StaffAccountIdquery (user.staffAccountId, a plain MPDX read with no SAA call). That saves one SAA account summary per page load for staff.BalanceCardnever leaves its skeleton up once loading ends:FundBalancesfails. That case used to stay hidden becauseStaffAccountfailed first for a user whose staff account SAA does not know. Now such a user passes the id check, so the card has to handle the failure itself. The same single "SAA Error" snackbar shows as before.{donationPeriodTotalSum && ...}printed a bare "0" (the field isInt!) and hid the total. The card now shows "Total Donations for this period $0.00".StaffAccount, and hides it (with noFundBalancescall) whenstaffAccountIdis null. The card renders nothing on a query error or with no Primary fund, and shows a zero total. All five fail on main./code-reviewat xhigh (fresh Opus agent) found no regressions. It traced impersonation, users with no staff account, an id SAA doesn't know, and loading through both versions.Jira ticket: MPDX-10092
API side of the same ticket: https://github.com/CruGlobal/mpdx_api/pull/3680 (independent; either can ship first)
Testing
StaffAccountIdandFundBalances, and noStaffAccountoperation.FundBalancesrequest is sent.Checklist:
/quality:agent-reviewcommand locally and fixed any relevant suggestions🤖 Generated with Claude Code