Skip to content

MPDX-9599 - Fix "Changing the fund resets the month filter" and other fixes#1789

Merged
zweatshirt merged 3 commits into
mainfrom
MPDX-9599
May 20, 2026
Merged

MPDX-9599 - Fix "Changing the fund resets the month filter" and other fixes#1789
zweatshirt merged 3 commits into
mainfrom
MPDX-9599

Conversation

@zweatshirt
Copy link
Copy Markdown
Contributor

@zweatshirt zweatshirt commented May 20, 2026

Description

  • Fixes the issue where changing the fund type resets the user set month filter.
  • Fixes the issue where users can't filter by category when navigating months normally.
  • Fixes the issue where setting 'None' in the date range filter fails to resolve back to the normal month-by-month flow

Testing

  • Go to reports/staffExpense
  • Test behavior of switching between fund types, ensuring that any existing date filters aren't reset.
  • Test that selecting 'None' for the date range filter in settings correctly resolves to the month-by-month flow
  • Check that category filters in the settings work well for the default month-by-month flow

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

@github-actions
Copy link
Copy Markdown
Contributor

Bundle sizes [mpdx-react]

Compared against 1514a65

No significant changes found

@zweatshirt
Copy link
Copy Markdown
Contributor Author

🤖 Multi-Agent Code Review — PR #1789

5 agents · Standard mode · Opus


Risk Assessment

Score: 4/10 — MEDIUM

Factor Points
3 medium-risk component files (*.tsx, *.ts) +3
Change volume: ~54 non-test lines (50–200 range) +1
Scope multiplier: single feature domain ×1.0

Required reviewer level: Any — changes are well-scoped to one feature area.


Agents Launched

Agent Included Reason
Architecture Always included
Testing Always included
Standards Always included
UX .tsx files changed
Financial Reporting Files under src/components/Reports/**
Security No auth/env/workflow files
Data Integrity No schema/migration/cache mutation changes

Verdict: ✅ APPROVED_WITH_SUGGESTIONS

No blocking issues. The three bugs are correctly fixed, the refactor is clean, and test coverage is solid. Suggestions below are all non-blocking quality improvements.


Findings

Concerns (4–6) — Non-blocking, worth addressing if easy

1. fetchPolicy: 'no-cache' lacks an explanatory comment (Architecture + Standards + Financial — consensus)

  • SettingsDialog.tsx line ~151
  • The no-cache policy is the correct fix for the Apollo cache collision between the parent report query (fundTypes: ['Primary', 'Savings', 'Staff Conference Savings']) and the dialog's category preview query (fundTypes: [selectedFundType]). Without a comment, future maintainers may remove it thinking it's a premature optimization.
  • Suggested fix: add an inline comment:
    // no-cache prevents this single-fund query from overwriting the parent
    // report's multi-fund cache entry, which caused fund-switching to reset filters
    fetchPolicy: 'no-cache',

2. mutationSpy declared at module scope in SettingsDialog.test.tsx (Testing)

  • SettingsDialog.test.tsx line 14
  • jest.clearAllMocks() in beforeEach mitigates cross-test contamination, but the two new tests at lines 425 and 441 share the same spy instance. If Jest runs them concurrently (unlikely with default config, but possible with --runInBand off), state bleed is possible.
  • Suggested fix: move declaration inside beforeEach or into the two tests that use it.

3. CircularProgress missing aria-label (UX)

  • SettingsDialog.tsx loading state
  • CircularProgress renders role="progressbar" by default, so it's not fully inaccessible, but screen readers won't announce what is loading.
  • Suggested fix:
    <CircularProgress size={24} aria-label={t('Loading categories')} />

4. Return type annotation overstates nullability (Standards)

  • getMonthRange.ts — return type is { startMonth: string | null; endMonth: string | null }
  • The ?? chain always falls back to baseTime.startOf('month').toISODate(), which returns null only if baseTime is an invalid DateTime — something that shouldn't happen at call sites. The | null is technically accurate to Luxon's type signature but misleads callers into thinking nulls are routine.
  • Optional: narrow to { startMonth: string; endMonth: string } with a non-null assertion (!) on the final fallback, or document the assumption.

Suggestions (1–3) — Low priority

5. DateWindow interface justified by circular-import constraint (Architecture — post-debate)

  • Architecture initially rated this 7.5, but Helpers/getMonthRange.ts cannot import Filters from SettingsDialog.tsx without creating a circular dependency (SettingsDialog imports from Helpers). DateWindow is the correct design. No action needed — the interface is appropriate.

6. Settings.now restoration in StaffExpenseReport.test.tsx (Testing — post-debate)

  • The manual Settings.now = originalNow at the end of the date filter test isn't protected by try-finally. In practice, the global beforeEach in __tests__/util/setup.ts resets it before the next test, so cross-test contamination is prevented. Low actual risk, but try-finally is a cleaner pattern for future maintainers to copy.

7. Date window asymmetry (startDate-only) worth a comment (Financial)

  • getMonthRange.ts: when only startDate is set (no endDate), endMonth falls back to baseTime (current viewed month), not the startDate's month. This is intentional (same as the pre-refactor inline logic) and tested explicitly. A short comment in the function would make the intent obvious.

Positive Observations

  • <Loading loading /><CircularProgress size={24} />: Correct fix. The old Loading component uses position: fixed (viewport overlay), which is wrong inside a dialog's DialogContent. The scoped inline spinner is the right pattern.
  • getMonthRange.ts extraction: All 6 code paths are unit-tested. The startDate-only asymmetric case (previously invisible in integration tests) is now explicitly documented by the test.
  • !filters!isFilterDateSelected: The root cause of the "month title disappearing on category-only filter" bug. Fix is minimal and correct.
  • fetchPolicy: 'no-cache' + skip: !isOpen: Together these correctly solve the cache-collision bug without architectural changes.
  • time prop on SettingsDialog: Ensures categories reflect the viewed month, not today's date — important for historical month navigation.

🤖 Generated with Claude Code/quality:agent-review (Standard mode, 5 agents)

@zweatshirt zweatshirt self-assigned this May 20, 2026
@zweatshirt zweatshirt added the Preview Environment Add this label to create an Amplify Preview label May 20, 2026
Copy link
Copy Markdown
Contributor Author

@zweatshirt zweatshirt left a comment

Choose a reason for hiding this comment

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

🤖 Multi-Agent Code Review — PR #1789

5 agents · Standard mode · Opus

Risk Score: 4/10 — MEDIUM | Verdict: ✅ APPROVED_WITH_SUGGESTIONS

No blocking issues. Suggestions posted as a PR comment.

@zweatshirt zweatshirt marked this pull request as ready for review May 20, 2026 15:34
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

AI Review Auto-Approval

Risk Level: MEDIUM (4/10)
Verdict: APPROVED_WITH_SUGGESTIONS (suggestions posted, no blockers)

This PR was auto-approved because:

  • The multi-agent AI review determined it is medium risk
  • No blocking issues were found
  • All suggestions have been posted as review comments for the developer to consider

If you believe this PR needs human review, dismiss this approval and request a review manually.

@github-actions
Copy link
Copy Markdown
Contributor

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

@zweatshirt zweatshirt merged commit f9b0c40 into main May 20, 2026
24 checks passed
@zweatshirt zweatshirt deleted the MPDX-9599 branch May 20, 2026 15:50
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.

1 participant