Skip to content

fix(card): don't render "#null" for a waitlist entry without a position#2437

Open
innolope-dev wants to merge 3 commits into
mainfrom
fix/physical-waitlist-null-position
Open

fix(card): don't render "#null" for a waitlist entry without a position#2437
innolope-dev wants to merge 3 commits into
mainfrom
fix/physical-waitlist-null-position

Conversation

@innolope-dev

@innolope-dev innolope-dev commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

The bug

The physical-card waitlist screen can tell a user they are "You are #null on the list."

getPhysicalWaitlist types the position as nullable (src/services/rain.ts):

export interface PhysicalWaitlistState {
    joinedAt: string | null
    position: number | null   // <-- nullable
}

…but PhysicalCardScreen renders the joined branch gated on joinedAt only, interpolating position regardless:

{`You are #${data.position} on the list. We'll let you know when cards are ready to be shipped.`}

A JS template literal stringifies null to "null", so a user who is on the list with no assigned queue position gets #null. The same component already treats the field as nullable a few lines up — position: data?.position ?? null for its PostHog event — which confirms null is a real, expected state rather than a type-only edge case.

This is not related to the earlier #16on#16 on spacing fix (#2311); that one repaired the spacing on this same line and left the null case untouched. The bug is live on main today.

The fix

Branch on the null case with its own sentence instead of interpolating a number that isn't there. Since the interpolation was being touched anyway, real positions now go through toLocaleString(), so a queue position of 1234 reads #1,234 rather than #1234.

Tests

New PhysicalCardScreen.test.tsx (the component had none) covering three cases: a normal position, the null case asserting no # reaches the body, and thousands-separator formatting.

The test was verified to actually catch the bug — against the original code the null and formatting cases fail (with exactly the reported #null) while the normal-position case still passes. A regression test that passes either way is worthless, so this was checked rather than assumed.

Verification

pnpm typecheck ✓ · jest PhysicalCardScreen 3/3 ✓ · eslint no new errors · prettier clean.

Summary by CodeRabbit

  • Bug Fixes

    • Improved waitlist messaging when a position is unavailable.
    • Formatted available waitlist positions using locale-aware number formatting (e.g., thousands separators).
    • Prevented confusing “#null” text from appearing.
  • Tests

    • Added coverage for both numeric waitlist positions and unavailable positions.

getPhysicalWaitlist types position as nullable and the joined branch is
gated on joinedAt, so a user on the list with no queue position was told
'You are #null on the list.' Drop the number for that case and format
real positions for readability.
@vercel

vercel Bot commented Jul 17, 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 17, 2026 1:08pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 17, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 45160198-d554-4824-acfc-d9d04aa800d3

📥 Commits

Reviewing files that changed from the base of the PR and between 9aad003 and 3b8466e.

📒 Files selected for processing (1)
  • src/components/Card/__tests__/PhysicalCardScreen.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Card/tests/PhysicalCardScreen.test.tsx

📝 Walkthrough

Walkthrough

PhysicalCardScreen handles null waitlist positions without rendering #null, formats numeric positions with locale separators, and adds tests for the joined-waitlist messages.

Changes

Waitlist copy handling

Layer / File(s) Summary
Conditional waitlist copy
src/components/Card/PhysicalCardScreen.tsx
Joined waitlist messaging renders “You are on the list.” for null positions and locale-formatted numbered copy otherwise.
Joined-waitlist copy tests
src/components/Card/__tests__/PhysicalCardScreen.test.tsx
Tests cover null positions, numeric positions, and thousands-separated formatting using mocked dependencies and a React Query provider.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: avoiding "#null" for waitlist entries without a position.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/physical-waitlist-null-position

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 failed: dependency version conflict. Check your lock file or package.json.


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

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 6207.05 → 6207.36 (+0.31)
Findings: 0 net (+2 new, -2 resolved)

🆕 New findings (2)

  • medium complexity — src/components/Card/PhysicalCardScreen.tsx — CC 12, MI 60.74, SLOC 47
  • low high-mdd — src/components/Card/PhysicalCardScreen.tsx:22 — PhysicalCardScreen: MDD 12.3 (uses across many lines from declarations)

✅ Resolved (2)

  • src/components/Card/PhysicalCardScreen.tsx — CC 11, MI 61.21, SLOC 46
  • src/components/Card/PhysicalCardScreen.tsx:22 — PhysicalCardScreen: MDD 12.0 (uses across many lines from declarations)

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1998 ran, 0 failed, 0 skipped, 34.8s

📊 Coverage (unit)

metric %
statements 59.5%
branches 43.3%
functions 48.4%
lines 59.8%
⏱ 10 slowest test cases
time test
4.0s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
1.2s src/utils/__tests__/demo-api.test.ts › isDemoMode() is false when not running under Capacitor
0.4s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.4s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in validateInviteCode
0.3s src/app/(mobile-ui)/withdraw/__tests__/withdraw-states.test.tsx › Bank withdrawal keeps the $1 minimum for sub-$1 amounts
0.3s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in validateInviteCode body
0.2s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › keeps stickers off the username pill (final pass respects the keep-out)
0.2s src/utils/__tests__/demo-balance.test.ts › debits and floors at zero
0.2s src/utils/__tests__/url.utils.test.ts › uses the public BASE_URL in Capacitor, not the localhost WebView origin
0.2s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Card/__tests__/PhysicalCardScreen.test.tsx`:
- Around line 55-59: Update the large-position test in PhysicalCardScreen to
derive the expected position text from the numeric value using toLocaleString(),
rather than hardcoding the comma-formatted “1,234” string. Keep the assertion’s
surrounding wording and existing mock behavior unchanged.

In `@src/components/Card/PhysicalCardScreen.tsx`:
- Around line 79-81: Update the position check in the PhysicalCardScreen display
expression to treat both null and undefined as the “on the list” state by using
a loose null comparison. Keep the toLocaleString formatting path for defined
position values.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eb6811f8-a9a3-4375-b4c8-24fd024222aa

📥 Commits

Reviewing files that changed from the base of the PR and between 5ab943f and 9aad003.

📒 Files selected for processing (2)
  • src/components/Card/PhysicalCardScreen.tsx
  • src/components/Card/__tests__/PhysicalCardScreen.test.tsx

Comment thread src/components/Card/__tests__/PhysicalCardScreen.test.tsx
Comment on lines +79 to +81
{data.position === null
? `You are on the list. We'll let you know when cards are ready to be shipped.`
: `You are #${data.position.toLocaleString()} on the list. We'll let you know when cards are ready to be shipped.`}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Use a loose equality check to prevent runtime crashes if position is undefined.

The strict equality check (=== null) will evaluate to false if the API omits the position field, making data.position undefined. This would cause the app to crash with a TypeError: Cannot read properties of undefined (reading 'toLocaleString').

Using a loose equality check (== null) handles both null and undefined safely.

🛡️ Proposed fix
-                        {data.position === null
+                        {data.position == null
                             ? `You are on the list. We'll let you know when cards are ready to be shipped.`
                             : `You are #${data.position.toLocaleString()} on the list. We'll let you know when cards are ready to be shipped.`}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{data.position === null
? `You are on the list. We'll let you know when cards are ready to be shipped.`
: `You are #${data.position.toLocaleString()} on the list. We'll let you know when cards are ready to be shipped.`}
{data.position == null
? `You are on the list. We'll let you know when cards are ready to be shipped.`
: `You are #${data.position.toLocaleString()} on the list. We'll let you know when cards are ready to be shipped.`}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Card/PhysicalCardScreen.tsx` around lines 79 - 81, Update the
position check in the PhysicalCardScreen display expression to treat both null
and undefined as the “on the list” state by using a loose null comparison. Keep
the toLocaleString formatting path for defined position values.

The hardcoded "1,234" assumed an en-US default locale, so the test failed
under any locale with a different thousands separator (de_DE renders 1.234).
Assert against toLocaleString output instead — that is the actual contract.

@kushagrasarathe kushagrasarathe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. Live bug — nullable position interpolated to "#null". === null branch is correct (keeps #0 valid, unlike a falsy check). toLocaleString() is a justified in-line extra and is tested. Regression test verified to fail pre-fix.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants