Skip to content

fix(chat): don't tell the viewer they received a group's cash - #1497

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/group-cash-preview-attribution
Sep 18, 2026
Merged

bmc08gt merged 1 commit into
code/cashfrom
fix/group-cash-preview-attribution

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

A group cash message previews as "You received $25.00" whenever the sender cannot be attributed. previewText reaches the else branch and picks label_chat_preview_receivedCash, which is wrong for a group: the cash went to the chat, and the viewer may have got none of it. The comment directly above already says so — the reasoning just never guarded this branch, only the senderName != null one.

It is reachable, not theoretical. The feed carries a truncated roster subset for a large group, so metadata.members often does not have the sender; a group cash message with a null senderId lands in the same place.

The fix: in a group, when the sender cannot be attributed and the message is not sentBySelf, preview the bare label — the formatted amount with the "of " suffix where it applies. That is what the named-sender branch already renders apart from its "Alice sent" prefix. previewText did not know the chat type, so isGroup is threaded in alongside sentBySelf and senderName, including through the MessageContent.Reply recursion. The self-sent and named-sender branches are unchanged.

ChatSummaryPreviewTest gains the cash counterpart of its existing a message from someone the roster subset omits is not prefixed: a group whose last message is MessageContent.Cash from an id outside members previews as $25.00. It fails on the old code — the unstubbed receivedCash lookup throws — and the module's suite passes with the fix.

This came from iOS. ConversationController.lastMessagePreview in code-payments/code-ios-app#799 took the same reading for the group cash case, so this closes the divergence rather than opening one.

A group cash message previews as "You received $25.00" whenever the sender
cannot be attributed — the feed carries a truncated roster for a large group,
so the sender is often missing from `metadata.members`, and a null `senderId`
lands in the same place. The cash went to the group; the viewer may have got
none of it.

Preview the bare amount instead, which is what the named-sender branch already
does apart from the "Alice sent" prefix. `previewText` needs `isGroup` to tell
the two unattributed cases apart, so thread it in alongside `sentBySelf` and
`senderName`.

Matches the reading iOS took in code-payments/code-ios-app#799.
@bmc08gt bmc08gt self-assigned this Sep 18, 2026
@github-actions github-actions Bot added the type: fix Bug fix label Sep 18, 2026
@bmc08gt
bmc08gt merged commit 84f56c8 into code/cash Sep 18, 2026
3 checks passed
@bmc08gt
bmc08gt deleted the fix/group-cash-preview-attribution branch September 23, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant