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
@@ -1,14 +1,18 @@
import {Fundraiser} from 'src/components/widget/types/Fundraiser';
import {Nonprofit} from 'src/components/widget/types/Nonprofit';
import {PaymentMethod} from 'src/components/widget/types/PaymentMethod';

export function getGranteeName(
nonprofit: Nonprofit,
parentNonprofit?: Nonprofit
) {
if (nonprofit.metadata?.granteeName) {
return nonprofit.metadata?.granteeName;
Comment on lines +9 to +10
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

This code expects granteeName to be a string value to return, but the type definition shows it as a boolean. This will cause incorrect behavior when the field is true but no actual name is provided.

Suggested change
if (nonprofit.metadata?.granteeName) {
return nonprofit.metadata?.granteeName;
// Only return granteeName if it is a non-empty string
if (typeof nonprofit.metadata?.granteeName === 'string' && nonprofit.metadata?.granteeName.trim() !== '') {
return nonprofit.metadata.granteeName;

Copilot uses AI. Check for mistakes.
}

const name = nonprofit.metadata?.prefixWithThe
? `the ${nonprofit.name}`
: nonprofit.name;

if (parentNonprofit) {
return `the fund for ${name} hosted at ${parentNonprofit.name}`;
}
Expand All @@ -20,15 +24,22 @@ export function isOfficialFundraiser(fundraiser: Fundraiser): boolean {
return fundraiser.nonprofitId === fundraiser.creatorNonprofitId;
}

const DAF_DEDUCTIBLE_STATEMENT =
'If you use a Donor Advised Fund (DAF), your receipt from Every.org will not be tax-deductible as the tax deduction was already received at the time you contributed to your DAF. For any other payment method, you will get a tax-deductible receipt emailed to you';

export const getTaxDeductibleStatement = (
nonprofit: Nonprofit,
fundraiser?: Fundraiser,
parentNonprofit?: Nonprofit
parentNonprofit?: Nonprofit,
paymentOption?: PaymentMethod
) => {
const granteeName = getGranteeName(nonprofit, parentNonprofit);
const deductibleStatement =
paymentOption === PaymentMethod.DAF
? DAF_DEDUCTIBLE_STATEMENT
: '100% of your donation is tax-deductible to the extent allowed by US law';

const base = `100% of your donation is tax-deductible to the extent allowed by US law.
Your donation is made to Every.org, a tax-exempt US 501(c)(3) charity that
const main = `${deductibleStatement}. Your donation is made to Every.org, a tax-exempt US 501(c)(3) charity that
grants unrestricted funds to ${granteeName} on your behalf.
As a legal matter, Every.org must provide any donations to ${granteeName} on an
unrestricted basis, regardless of any designations or restrictions made by
Expand All @@ -37,19 +48,22 @@ export const getTaxDeductibleStatement = (
const isUnofficialFundraiser =
fundraiser && !isOfficialFundraiser(fundraiser);

let end = '';
let noPermission = '';

const nonprofitNameWithVerb = `${nonprofit.name} has`;
if (nonprofit.hasAdmin && isUnofficialFundraiser) {
end = `Please note ${nonprofit.name} has not reviewed or approved the content of this peer-to-peer fundraiser.`;
noPermission = `Please note ${nonprofitNameWithVerb} not reviewed or approved the content of this peer-to-peer fundraiser.`;
} else if (!nonprofit.hasAdmin && !isUnofficialFundraiser) {
end = `Please note ${nonprofit.name} has not provided permission for this solicitation.`;
noPermission = `Please note ${nonprofitNameWithVerb} not provided permission for this solicitation.`;
} else if (!nonprofit.hasAdmin && isUnofficialFundraiser) {
end = `Please note ${nonprofit.name} has not provided permission for this solicitation or reviewed or approved the content of this peer-to-peer fundraiser.`;
noPermission = `Please note ${nonprofitNameWithVerb} not provided permission for this solicitation or reviewed or approved the content of this peer-to-peer fundraiser.`;
}

const customTaxDeductible = nonprofit.metadata?.customTaxDeductible ?? '';

return (
<span>
{base} {end}
{main} {noPermission} {customTaxDeductible}
</span>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export interface Nonprofit {
logoUrl: string | null;
nteeCode: string | null;
metadata?: {
customTaxDeductible?: string;
disablePrivateNotes?: boolean;
granteeName?: string;
prefixWithThe?: boolean;
hideFundraiseButton?: boolean;
};
Expand Down