Skip to content

fix(request): show Completed on a fully funded request pot#2430

Open
innolope-dev wants to merge 1 commit into
mainfrom
fix/request-pot-status-badge
Open

fix(request): show Completed on a fully funded request pot#2430
innolope-dev wants to merge 1 commit into
mainfrom
fix/request-pot-status-badge

Conversation

@innolope-dev

Copy link
Copy Markdown
Collaborator

The issue

A request pot that had been fully paid still showed a Pending badge, even with the progress bar at 100% and $0 remaining right next to it:

Request $1,750.00Pending$1750 contributed / $0 remaining

Why it happened

The badge wasn't reading the collected amount at all — it was reading the wrong field entirely.

A request link's status is an OPEN/CLOSED enum on the backend (RequestLinkStatus). It only flips to CLOSED when the requester explicitly closes the request, so it never reports "the goal was met". Meanwhile mapEntryStatusToUiStatus in transactionTransformer.ts had no case 'OPEN' at all, so an open pot fell through to the default branch:

default: {
    const knownStatuses: StatusType[] = ['completed', 'pending', 'failed', 'cancelled', 'soon', 'processing']
    const lower = entry.status?.toLowerCase()   // 'open' — not a known status
    return lower && knownStatuses.includes(lower as StatusPillType) ? (lower as StatusPillType) : 'pending'
}

'open' isn't in knownStatuses, so every open pot returned 'pending'. A fully funded pot and an untouched one were indistinguishable to the badge.

Compounding it: OPEN wasn't even a member of the frontend's EHistoryStatus enum, even though the backend sends it — history.ts casts past the type (link.status as HistoryEntry['status']), so nothing flagged the gap.

The fix

For request links with status OPEN, derive the badge from the collected sum against the goal — the same data the progress bar already renders:

if (entry.isRequestLink && status === 'OPEN') {
    const goal = Number(entry.amount ?? 0)
    return goal > 0 && (entry.totalAmountCollected ?? 0) >= goal ? 'completed' : 'pending'
}

goal > 0 guards the "no goal set" pot, which can never be fully funded — without it, such a pot would flip to Completed instantly. Closed pots keep their existing closed/cancelled behaviour, which is decided further down the switch.

OPEN is also added to EHistoryStatus so the type reflects what actually arrives on the wire.

Tests

5 new cases in transactionTransformer.test.ts covering exactly-funded, over-funded, partially funded, goal-less, and closed pots. Full TransactionDetails suite passes (39 in this file), tsc clean.

Related

The number this badge now keys off is summed on the backend, and the requester's rollup and the payer's request route were computing it two different ways (intent COMPLETED + requested amount vs. entry-backed SUCCESSFUL + settled amount). That's fixed separately in a peanut-api-ts PR. This change is independent and safe to ship on its own — it just inherits whatever the current sum reports until that lands.

A request link's status is an OPEN/CLOSED column that only flips to CLOSED
when the requester explicitly closes it, so it never reports that the goal
was met. mapEntryStatusToUiStatus had no OPEN case and fell through to the
default branch, which returns 'pending' — so a fully funded pot and an
untouched one rendered the same "Pending" badge, even at $0 remaining.

Derive the badge from the collected sum against the goal for OPEN request
links, which is the same data the progress bar already renders. Goal 0 is
the "no goal set" pot and can never be fully funded, so it stays pending.

Also add OPEN to EHistoryStatus — the backend casts past the type when it
sends the field, so nothing flagged that the enum was missing a value the
wire actually carries.
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peanut-wallet Ready Ready Preview, Comment Jul 16, 2026 11:19am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2d8e9728-66a2-405c-a750-bc7c197151e6

📥 Commits

Reviewing files that changed from the base of the PR and between 3115088 and d90fb57.

📒 Files selected for processing (3)
  • src/components/TransactionDetails/__tests__/transactionTransformer.test.ts
  • src/components/TransactionDetails/transactionTransformer.ts
  • src/utils/history.utils.ts

Walkthrough

Adds OPEN history status support and maps request pot rollup entries to completed when their collected amount meets the positive goal, otherwise pending, while preserving closed status.

Changes

Request pot status

Layer / File(s) Summary
Request pot status mapping
src/utils/history.utils.ts, src/components/TransactionDetails/transactionTransformer.ts, src/components/TransactionDetails/__tests__/transactionTransformer.test.ts
Adds the OPEN history status, derives request pot UI status from goal progress, and tests funded, partially funded, goal-less, overfunded, and closed cases.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested labels: enhancement

Suggested reviewers: kushagrasarathe

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fully funded request pots now show Completed instead of Pending.
Description check ✅ Passed The description accurately explains the bug, fix, and tests, and it matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 6121.74 → 6122.26 (+0.52)
Findings: 0 net (+9 new, -9 resolved)

🆕 New findings (9)

  • critical complexity — src/components/TransactionDetails/transactionTransformer.ts — CC 100, MI 43.81, SLOC 279
  • high hotspot — src/components/TransactionDetails/transactionTransformer.ts — 40 commits, +907/-773 lines since 6 months ago
  • high method-complexity — src/components/TransactionDetails/transactionTransformer.ts:168 — mapEntryStatusToUiStatus CC 36 SLOC 55
  • high method-complexity — src/components/TransactionDetails/transactionTransformer.ts:465 — mapTransactionDataForDrawer CC 34 SLOC 138
  • high method-complexity — src/utils/history.utils.ts:331 — completeHistoryEntry CC 31 SLOC 114
  • medium high-mdd — src/components/TransactionDetails/transactionTransformer.ts:465 — mapTransactionDataForDrawer: MDD 98.5 (uses across many lines from declarations)
  • medium high-mdd — src/utils/history.utils.ts:331 — completeHistoryEntry: MDD 53.7 (uses across many lines from declarations)
  • medium high-mdd — src/components/TransactionDetails/transactionTransformer.ts:168 — mapEntryStatusToUiStatus: MDD 20.0 (uses across many lines from declarations)
  • low high-mdd — src/components/TransactionDetails/transactionTransformer.ts:244 — computeDerivedFields: MDD 16.5 (uses across many lines from declarations)

✅ Resolved (9)

  • src/components/TransactionDetails/transactionTransformer.ts — CC 96, MI 44.17, SLOC 275
  • src/components/TransactionDetails/transactionTransformer.ts — 39 commits, +899/-773 lines since 6 months ago
  • src/components/TransactionDetails/transactionTransformer.ts:457 — mapTransactionDataForDrawer CC 34 SLOC 138
  • src/components/TransactionDetails/transactionTransformer.ts:168 — mapEntryStatusToUiStatus CC 32 SLOC 51
  • src/utils/history.utils.ts:330 — completeHistoryEntry CC 31 SLOC 114
  • src/components/TransactionDetails/transactionTransformer.ts:457 — mapTransactionDataForDrawer: MDD 98.5 (uses across many lines from declarations)
  • src/utils/history.utils.ts:330 — completeHistoryEntry: MDD 53.7 (uses across many lines from declarations)
  • src/components/TransactionDetails/transactionTransformer.ts:168 — mapEntryStatusToUiStatus: MDD 16.9 (uses across many lines from declarations)
  • src/components/TransactionDetails/transactionTransformer.ts:236 — computeDerivedFields: MDD 16.5 (uses across many lines from declarations)

@github-actions

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1841 ran, 0 failed, 0 skipped, 30.6s

📊 Coverage (unit)

metric %
statements 58.2%
branches 42.3%
functions 47.0%
lines 58.3%
⏱ 10 slowest test cases
time test
4.2s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
0.5s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.3s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in updateUserById
0.3s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › keeps stickers off the username pill (final pass respects the keep-out)
0.3s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in updateUserById body
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
0.1s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Perk claim in progress shows disabled button + progress
0.1s src/services/__tests__/resolveClaimLink.test.ts › restores the pristine password after a redirect mangles the fragment
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle invalid ETH address (missing 0x prefix)
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle minimum length (6 digits) US account
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants