Fix friend creation and direct expense ledger lifecycle - #40
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22e550cc22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!matchingFriend) { | ||
| if ( | ||
| !createdDirectGroupForExpense && |
There was a problem hiding this comment.
Block name fallback for freshly created direct ledgers
When a first-expense request supplies an unregistered counterparty ID whose participant name matches exactly one confirmed friend, this new guard disables only the group-membership fallback; the name-based fallback at lines 925–933 still accepts the request. The mutation consequently creates a ledger and expense for an identity absent from account_friends, so every legacy fallback—not only this branch—must be excluded when createdDirectGroupForExpense is true.
AGENTS.md reference: apps/backend/convex/AGENTS.md:L36-L37
Useful? React with 👍 / 👎.
| const existingGroupByClientId = await ctx.db | ||
| .query("groups") | ||
| .withIndex("by_client_id", (q) => q.eq("id", args.group_id)) | ||
| .unique(); | ||
|
|
||
| if (!existingGroupByClientId && !existing && requestedContextKind === "direct") { |
There was a problem hiding this comment.
Reuse identity-equivalent direct ledgers before inserting
If another device creates the direct ledger after this client opens a transient Add Expense draft, or two devices save concurrently, each draft has a different UUID; therefore existingGroupByClientId is null and this branch inserts another direct ledger without checking the owner's existing ledgers for the same identity-equivalent counterparty. This leaves permanent duplicate ledgers and causes future direct expenses to reuse whichever duplicate happens to be returned first.
AGENTS.md reference: AGENTS.md:L69-L71
Useful? React with 👍 / 👎.
|
Retriggering CI for the unchanged tested head after the synchronize event did not create a GitHub Actions run. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8797b70a06
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Confirmed friends plus explicit friends drafted in this creation flow. | ||
| private var allFriends: [GroupMember] { | ||
| let existing = store.friendMembers | ||
| let existing = store.confirmedFriends |
There was a problem hiding this comment.
Reuse known participant identities for typed friends
When someone already exists only as a group participant and the user types that same name under Add New Friend, switching allFriends to confirmedFriends prevents the existing identity from being found; the unchanged fallback then creates a fresh UUID, and addGroupAndSync persists it as a separate friend. This splits one person across balances, linking, and future groups. Keep the picker restricted to confirmed friends, but resolve typed additions through manualFriendCandidate(named:), as the standalone add-friend flow does.
AGENTS.md reference: apps/ios/PayBack/Sources/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
Summary
Verification