Skip to content

Map program types#3282

Draft
thewatermethod wants to merge 6 commits intomainfrom
mb/TTAHUB/map-program-types
Draft

Map program types#3282
thewatermethod wants to merge 6 commits intomainfrom
mb/TTAHUB/map-program-types

Conversation

@thewatermethod
Copy link
Collaborator

@thewatermethod thewatermethod commented Feb 5, 2026

Description of change

The following program types are equivalent, filters should reflect that

  • EHS = AIAN EHS
  • HS = AIAN HS

Note that only "EHS" and "HS" are valid inputs so we don't need to map the inverse, despite Copilot's concerns

How to test

Validate the above change is properly mapped and filters reflect it

Issue(s)

Checklists

Every PR

  • Meets issue criteria
  • JIRA ticket status updated
  • Code is meaningfully tested
  • Meets accessibility standards (WCAG 2.1 Levels A, AA)
  • API Documentation updated
  • Boundary diagram updated
  • Logical Data Model updated
  • Architectural Decision Records written for major infrastructure decisions
  • UI review complete
  • QA review complete

Before merge to main

  • OHS demo complete
  • Ready to create production PR

Production Deploy

  • PR created as Draft
  • Staging smoke test completed
  • PR transitioned to Open
  • Reviewer added (after transitioning to Open to ensure Slack notifications trigger)
    • Sequence: Draft PR → Smoke test → Open PR → Add reviewer
    • Confirm that Slack notification was sent after reviewer was added

After merge/deploy

  • Update JIRA ticket status

@thewatermethod thewatermethod marked this pull request as ready for review February 5, 2026 19:17
Copilot AI review requested due to automatic review settings February 5, 2026 19:17
Copy link
Contributor

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 PR implements program type mapping to treat certain program types as equivalent: 'EHS' and 'AIAN EHS' are treated as equivalent, as are 'HS' and 'AIAN HS'. A new utility function filterToAllowedProgramTypes is introduced to expand program type filters, and this function is integrated into the grants, goals, and activity report filtering logic.

Changes:

  • Added ALLOWED_PROGRAM_TYPE_MAP constant and filterToAllowedProgramTypes function to expand program type filters
  • Updated program type filtering in grants, goals, and activity reports to use the new mapping function
  • Modified test data and expectations to reflect the new equivalence behavior

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/scopes/utils.ts Added mapping constant and utility function to expand program types based on equivalence rules
src/scopes/grants/programType.js Updated to use filterToAllowedProgramTypes for both inclusion and exclusion filters
src/scopes/goals/programType.js Updated to use filterToAllowedProgramTypes for both inclusion and exclusion filters
src/scopes/activityReport/programType.js Updated to use filterToAllowedProgramTypes for both inclusion and exclusion filters
src/scopes/grants/testHelpers.js Changed test data from 'HS' to 'AIAN HS' to validate the mapping behavior
src/scopes/activityReport/programType.test.js Updated test setup and expectations to reflect that filtering by 'EHS' now also includes 'AIAN EHS'


const ALLOWED_PROGRAM_TYPE_MAP = {
EHS: ['EHS', 'AIAN EHS'],
HS: ['HS', 'AIAN HS'],
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The mapping appears to be one-directional, but the PR description states that 'EHS = AIAN EHS' and 'HS = AIAN HS', suggesting equivalence. If users can filter by 'AIAN EHS' or 'AIAN HS' directly, the current implementation would return no results. Consider adding reverse mappings (e.g., 'AIAN EHS': ['EHS', 'AIAN EHS'] and 'AIAN HS': ['HS', 'AIAN HS']) to ensure bidirectional equivalence, or document why the mapping is intentionally one-directional.

Suggested change
HS: ['HS', 'AIAN HS'],
HS: ['HS', 'AIAN HS'],
'AIAN EHS': ['EHS', 'AIAN EHS'],
'AIAN HS': ['HS', 'AIAN HS'],

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

Choose a reason for hiding this comment

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

Only valid inputs are EHS & HS

Comment on lines +214 to +218
export function filterToAllowedProgramTypes(programTypes: string[]): string[] {
// eslint-disable-next-line max-len
const allowedTypes = programTypes.map((type) => ALLOWED_PROGRAM_TYPE_MAP[type] || null).filter(Boolean).flat();
return Array.from(new Set(allowedTypes));
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The function lacks JSDoc documentation. Given that other exported functions in this file have documentation (see compareDate, withinDateRange, filterAssociation, scopeToWhere, getValidTopicsSet), this function should also have documentation explaining its purpose, parameters, return value, and the mapping behavior.

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

Choose a reason for hiding this comment

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

Added JSDoc

Comment on lines +215 to +217
// eslint-disable-next-line max-len
const allowedTypes = programTypes.map((type) => ALLOWED_PROGRAM_TYPE_MAP[type] || null).filter(Boolean).flat();
return Array.from(new Set(allowedTypes));
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The function has a critical logic error: when a program type that's not a key in ALLOWED_PROGRAM_TYPE_MAP is passed (e.g., 'AIAN HS', 'AIAN EHS', 'Migrant HS', etc.), it returns an empty array instead of preserving those program types. This means filtering by 'AIAN HS' directly would return no results.

The function should preserve program types that aren't in the map. Consider this logic instead: for each type, if it exists as a key in the map, expand it to its mapped values; otherwise, keep the original type unchanged.

Suggested change
// eslint-disable-next-line max-len
const allowedTypes = programTypes.map((type) => ALLOWED_PROGRAM_TYPE_MAP[type] || null).filter(Boolean).flat();
return Array.from(new Set(allowedTypes));
const expandedTypes = programTypes.flatMap((type) => {
const mapped = ALLOWED_PROGRAM_TYPE_MAP[type];
if (Array.isArray(mapped)) {
return mapped;
}
if (mapped) {
return [mapped];
}
// If there is no mapping for this type, preserve the original type.
return [type];
});
return Array.from(new Set(expandedTypes));

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

Choose a reason for hiding this comment

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

This is not an error; we only want valid types returned


const ALLOWED_PROGRAM_TYPE_MAP = {
EHS: ['EHS', 'AIAN EHS'],
HS: ['HS', 'AIAN HS'],
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The ALLOWED_PROGRAM_TYPE_MAP is incomplete. According to the seed data and existing tests, there are at least six program types in use: 'HS', 'EHS', 'AIAN HS', 'AIAN EHS', 'Migrant HS', and 'Migrant EHS'. Consider whether 'Migrant HS' should map to an expanded list similar to how 'HS' maps to both 'HS' and 'AIAN HS', and similarly for 'Migrant EHS'.

Suggested change
HS: ['HS', 'AIAN HS'],
HS: ['HS', 'AIAN HS'],
'AIAN EHS': ['AIAN EHS'],
'AIAN HS': ['AIAN HS'],
'Migrant EHS': ['Migrant EHS'],
'Migrant HS': ['Migrant HS'],

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

Choose a reason for hiding this comment

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

Not incomplete; only valid inputs are EHS & HS

Copy link
Collaborator

Choose a reason for hiding this comment

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

the 'Migrant' variations should also map to the HS and EHS right?

Copy link
Collaborator

@AdamAdHocTeam AdamAdHocTeam left a comment

Choose a reason for hiding this comment

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

Left minor question

@thewatermethod thewatermethod marked this pull request as draft February 12, 2026 15:10
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.

3 participants