Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ const usePaymentMethods = () => {
() =>
methods
.filter((method) => {
// There is a bug where instead of being a proper array of disabled methods,
// it comes as an array of length 1 with a comma-separated string inside
if (
nonprofit?.metadata?.disabledPaymentFlowOptions?.includes(method)
nonprofit?.metadata?.disabledPaymentFlowOptions?.length === 1 &&
nonprofit?.metadata?.disabledPaymentFlowOptions[0]?.includes(method)
Comment on lines +51 to +52
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

The logic assumes the array always has exactly length 1, but only checks for length === 1 without handling cases where the array might be empty or have multiple elements. Consider using nonprofit?.metadata?.disabledPaymentFlowOptions?.[0]?.includes(method) instead, which safely handles all array lengths without the explicit length check.

Suggested change
nonprofit?.metadata?.disabledPaymentFlowOptions?.length === 1 &&
nonprofit?.metadata?.disabledPaymentFlowOptions[0]?.includes(method)
nonprofit?.metadata?.disabledPaymentFlowOptions?.[0]?.includes(method)

Copilot uses AI. Check for mistakes.
) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export interface Nonprofit {
nteeCode: string | null;
metadata?: {
customTaxDeductible?: string;
// Note that multiple payment methods can be disabled, but it still arrives as a single
// comma-separated string from the API eg "card,paypal" so we type it as such here
disabledPaymentFlowOptions?: string;
// Note that multiple payment methods can be disabled, but for some reason it arrives
// as an array of length 1 eg ["card,paypal"] from the API, so we type it as such here
disabledPaymentFlowOptions?: string[];
disablePrivateNotes?: boolean;
granteeName?: string;
prefixWithThe?: boolean;
Expand Down