diff --git a/components/Bounty/lib/bountyUtil.ts b/components/Bounty/lib/bountyUtil.ts index d5cafce2..d2f895a8 100644 --- a/components/Bounty/lib/bountyUtil.ts +++ b/components/Bounty/lib/bountyUtil.ts @@ -529,6 +529,18 @@ export const isFoundationBounty = (bounty: Bounty): boolean => { return creatorUserId === FOUNDATION_USER_ID; }; +/** + * Gets the RSC amount from a bounty, preferring totalAmount if it's greater than 0. + * This handles the case where totalAmount might be '0' due to ignoreBaseAmount transformation. + * + * @param bounty The bounty to get the amount from + * @returns The RSC amount as a number + */ +const getRscAmount = (bounty: Bounty): number => { + const totalAmount = Number.parseFloat(bounty.totalAmount || '0'); + return totalAmount > 0 ? totalAmount : Number.parseFloat(bounty.amount || '0'); +}; + /** * Calculates the display amount for a bounty in USD. * For Foundation bounties, returns a flat $150 USD. @@ -543,7 +555,7 @@ export const calculateBountyDisplayAmountUSD = (bounty: Bounty, exchangeRate: nu return FOUNDATION_BOUNTY_FLAT_USD; } - const rscAmount = parseFloat(bounty.totalAmount || bounty.amount || '0'); + const rscAmount = getRscAmount(bounty); return Math.round(rscAmount * exchangeRate); }; @@ -571,7 +583,7 @@ export const getBountyDisplayAmount = ( showUSD: boolean ): { amount: number; isFoundation: boolean } => { const isFoundation = isFoundationBounty(bounty); - const rscAmount = parseFloat(bounty.totalAmount || bounty.amount || '0'); + const rscAmount = getRscAmount(bounty); if (isFoundation) { if (showUSD) {