fix(qa): post-cutover FE crashes + receipt label regressions#1910
Conversation
Companion to peanut-api-ts PR #675. Five FE files patched to defensively handle the Account shape regressions surfaced by the staging cutover and to clean up two receipt-rendering bugs. 1. AddWithdrawRouterView.tsx — onAccountClick read `account.details.countryName` directly. After the cutover `details` was null on every legacy bank account (no provider_account_links row). Optional-chain via `account.details?.countryName ?? ''` so the click handler doesn't crash before the user can pick the account. Backend PR #675 also fixes the API to never emit null details, but the FE should be defensive in case any path produces null. 2. SavedAccountsView.tsx — `countryCodeForFlag` was conditionally rendered, so accounts without a country showed an empty space under the bank badge (Hugo screenshotted this). Add a neutral grey placeholder with the bank icon so the row reads as intentional rather than broken. 3. TransactionDetailsHeaderCard.tsx — the link-transaction short-circuit only fired when `(status === pending || cancelled || !userName)`. On `completed` it fell through to the generic "Sent to ${displayName}" composition, producing "Sent to Sent via link" for completed link sends. Drop the gate so link transactions always short-circuit; explicit per-status handling for send/receive renders "You sent via link" / "You received via link". 4. BankFlowManager.view.tsx — two reads of `account.details.countryCode` and one of `account.details.accountOwnerName` optional-chained. Same defensive pattern. 5. utils/bridge.utils.ts — getCountryFromAccount optional-chains on `account.details?.countryCode/countryName`. Same. All five changes are surgical (33 insertions, 12 deletions) and pass `pnpm typecheck` + `npm test` (928 tests, 36 suites).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughNull-safe access for account/details and country handling, URL-encoding for withdraw navigation, a fallback UI icon when country flags are missing, and simplified link-transaction title logic that derives titles from direction and completion status. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Review rate limit: 2/5 reviews remaining, refill in 33 minutes and 57 seconds. Comment |
Code-analysis diffPainscore total: 5541.9 → 5543.03 (+1.13) 🆕 New findings (14)
✅ Resolved (14)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/Claim/Link/views/BankFlowManager.view.tsx (1)
259-274:⚠️ Potential issue | 🔴 CriticalFix remaining unsafe
detailsdereference in the same null-safety block.Line 260 still uses
addBankAccountResponse.data.details.accountOwnerNamedirectly. Ifdetailsisnull, this path still crashes before the new fallback on Line 273 is useful.Suggested fix
- name: addBankAccountResponse.data.details.accountOwnerName || user?.user.fullName || '', + name: addBankAccountResponse.data.details?.accountOwnerName || user?.user.fullName || '',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/Claim/Link/views/BankFlowManager.view.tsx` around lines 259 - 274, The bankDetails construction still dereferences addBankAccountResponse.data.details.accountOwnerName unsafely; update the name assignment in the bankDetails object (the code around bankDetails and addBankAccountResponse) to use optional chaining and the existing fallbacks (e.g., addBankAccountResponse.data.details?.accountOwnerName ?? user?.user.fullName ?? '') so the path won’t throw when details is null and behavior matches the other nullable fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/AddWithdraw/AddWithdrawRouterView.tsx`:
- Around line 221-239: The onAccountClick handler currently sets countryPath
from account.details?.countryName which can be empty and drop the provided
_path; change the fallback so countryPath uses _path when
account.details?.countryName is falsy (e.g., const countryPath =
account.details?.countryName ?? _path ?? ''), then pass that countryPath into
setSelectedMethod and the router.push URL (used when account.type ===
AccountType.MANTECA) so the method state and Manteca URL are always populated.
In `@src/utils/bridge.utils.ts`:
- Around line 168-170: The lookup for countryInfo uses
account.details?.countryName to choose between name-search and code-search but
if the name is present and not found it returns undefined instead of falling
back; change the logic around countryInfo so it first tries
ALL_METHODS_DATA.find by name using account.details?.countryName
(case-insensitive) and, if that result is falsy, then try ALL_METHODS_DATA.find
by id using threeLetterCountryCode (i.e., attempt name match then fallback to
code match), referencing countryInfo, ALL_METHODS_DATA,
account.details?.countryName and threeLetterCountryCode.
---
Outside diff comments:
In `@src/components/Claim/Link/views/BankFlowManager.view.tsx`:
- Around line 259-274: The bankDetails construction still dereferences
addBankAccountResponse.data.details.accountOwnerName unsafely; update the name
assignment in the bankDetails object (the code around bankDetails and
addBankAccountResponse) to use optional chaining and the existing fallbacks
(e.g., addBankAccountResponse.data.details?.accountOwnerName ??
user?.user.fullName ?? '') so the path won’t throw when details is null and
behavior matches the other nullable fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6ec62182-6213-4bfc-b4d6-88d4baff1676
📒 Files selected for processing (5)
src/components/AddWithdraw/AddWithdrawRouterView.tsxsrc/components/Claim/Link/views/BankFlowManager.view.tsxsrc/components/Common/SavedAccountsView.tsxsrc/components/TransactionDetails/TransactionDetailsHeaderCard.tsxsrc/utils/bridge.utils.ts
Per /simplify review of PR #1910. Net -22 lines. - Drop the 3 inline comment blocks narrating staging history. - Collapse the 4-case getTitle switch to a lookup map keyed on direction. Same behavior, less branching. 928 tests pass.
- AddWithdrawRouterView: use the path arg from SavedAccountsView as fallback when account.details.countryName is empty so the Manteca withdraw URL doesn't drop country context. Also URL-encode country + destination to handle accents/spaces. - bridge.utils.getCountryFromAccount: if countryName lookup misses (legacy 'usa' etc.), fall back to threeLetterCountryCode instead of returning undefined.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/utils/bridge.utils.ts`:
- Around line 162-172: The fallback currently compares threeLetterCountryCode
(account.details.countryCode, an ISO3 value) against ALL_METHODS_DATA.id (ISO2),
causing misses; update the lookup in this module so the final return compares
threeLetterCountryCode to ALL_METHODS_DATA entries' iso3 field (c.iso3) and/or
supports both by checking c.iso3 === threeLetterCountryCode || c.id ===
threeLetterCountryCode, keeping the earlier byName lookup intact; update
references around threeLetterCountryCode, ALL_METHODS_DATA.find, and the return
expression to use c.iso3 (and optionally c.id) so non-US accounts resolve
correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e8fd6930-37fd-448f-b6d5-4ed2b9da66fb
📒 Files selected for processing (2)
src/components/AddWithdraw/AddWithdrawRouterView.tsxsrc/utils/bridge.utils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/AddWithdraw/AddWithdrawRouterView.tsx
Bridge stores countryCode as ISO3 ('USA', 'GBR') but CountryData.id is
ISO2. The previous fallback `c.id === threeLetterCountryCode` matched
nothing for non-US accounts when the countryName lookup missed. Now
checks both `c.iso3` and `c.id` so the fallback actually fires.
Summary
Companion to backend PR peanutprotocol/peanut-api-ts#675. Five FE files defensively handle Account-shape regressions from the staging cutover and fix two receipt-rendering bugs surfaced in Hugo's manual QA pass.
Bugs fixed
Saved-accounts page crash —
Cannot read properties of null (reading 'countryName')atAddWithdrawRouterView.onAccountClick. After the phase-2 consolidate, every legacy account haddetails: nullbecauseprovider_account_linkswas empty. The handler crashed onaccount.details.countryNamebefore the user could even act on the account. Backend PR [TASK-7066] refactor: new endpoints request #675 also makes the API always emit a non-nulldetailsshape; this FE patch is the second line of defense."Sent to Sent via link" drawer header on completed link sends. The link-transaction short-circuit in
TransactionDetailsHeaderCard.getTitleonly fired when(status === 'pending' || 'cancelled' || !userName), so completed link sends fell through to the genericSent to ${displayName}composition wheredisplayName === 'Sent via link'. Now the short-circuit fires for any link transaction with explicit per-status / per-direction handling.Missing icon on saved bank accounts whose
countryCodeForFlagis empty (legacy accounts without provider-link metadata). The 8x8 flag image was conditionally rendered, leaving a bare yellow bank badge floating over empty space. Added a grey placeholder so the row reads as intentional.account.details?.countryCode/accountOwnerNameoptional-chained inBankFlowManager.view.tsx(2 sites) andbridge.utils.ts.getCountryFromAccount— defensive coverage of the same null-detailsregression on lower-traffic paths.Files
AddWithdraw/AddWithdrawRouterView.tsx?.countryName ?? ''optional-chain inonAccountClickCommon/SavedAccountsView.tsxcountryCodeForFlagis emptyTransactionDetails/TransactionDetailsHeaderCard.tsx(pending|cancelled|!userName)gate; explicit per-direction handlingClaim/Link/views/BankFlowManager.view.tsx?.countryCode ?? ''and?.accountOwnerNameutils/bridge.utils.tsaccount.details?.countryCode/countryNameTest plan
pnpm typecheckcleannpm test— 928 tests / 36 suites passRisk
Surgical: 33 insertions, 12 deletions across 5 files. All changes are NULL-safe optional-chains or additive UI fallbacks; no business logic touched. Pairs with backend PR #675 — that PR makes the API never return
details: null; this patch makes the FE robust even if it does.