Skip to content

feat: show the payer's own share on expense details - #819

Open
joshtgl wants to merge 1 commit into
oss-apps:mainfrom
joshtgl:feat/expense-details-owes-gets-back
Open

joshtgl wants to merge 1 commit into
oss-apps:mainfrom
joshtgl:feat/expense-details-owes-gets-back

Conversation

@joshtgl

@joshtgl joshtgl commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

On the expense details page, the person who paid is listed with only what they get back, so their own share of the cost isn't shown. This PR adds it on the same line: "You owe $40 and get back $50". Everyone else's line is unchanged ("Sam Rivera owes $30").

Why

Right now it's hard to tell how an expense was split. Everyone else's line shows their share directly. The payer's line shows only the net amount they get back, so you have to work out their share yourself:

Current With this change
You paid $90 You paid $90
You get $50 You owe $40 and get back $50
Sam Rivera owes $30 Sam Rivera owes $30
Jordan Lee owes $20 Jordan Lee owes $20

In the current view, you can't see at a glance whether the payer took an equal part or a different one. You have to subtract what they get back from what they paid. With the payer's share on their line, every person's share is listed, and you can see how the cost was divided without doing any math.

What changes

  • The payer's line reads "owes X and gets back Y". X is their share and Y is what they get back.
  • Unchanged:
    • a payer who isn't part of the split: still "gets Y"
    • everyone else's lines
    • refunds (negative expenses)
    • settlements and currency conversions, which move money between people rather than splitting a cost
  • No backend or schema change. Each participant's stored amount is already what they paid minus their share. An expense has one payer, so the payer's share is the expense amount minus their stored amount.
  • Lines on the details page now wrap on narrow screens. Before, a long name could push the amount off-screen at phone width. This also affects the existing "X paid $Y" line.
  • NON_SPENDING_SPLIT_TYPES moves from src/lib/groupStatistics.ts to a new src/lib/splitTypes.ts. This PR uses it too, to decide which expenses get the new line. It's a pure move with an added isSpendingSplitType helper, and the group statistics queries (feat: show paid and share of costs per person in group statistics #807) behave the same.

Demo

Screenshots are at 390px wide, except the last one at 360px. Both uneven examples are a $90 dinner split $40 / $30 / $20. Before, the payer's $40 share isn't shown anywhere.

You paid, uneven split

Before After
5-uneven-you-paid 5-uneven-you-paid

Someone else paid, uneven split

Before After
6-uneven-someone-else-paid 6-uneven-someone-else-paid

Long name on a narrow phone (360px)

Before After
4-phone-long-names 4-phone-long-names

Testing

  • Unit tests for the share calculation and for which expenses show it (src/tests/expenseShare.test.ts).
  • The group expense E2E test now checks both the payer's line and the other person's line on the details page (tests/e2e/group-expense.spec.ts).
  • The group statistics integration test still passes after the constant was moved.

Checklist

  • I have read CONTRIBUTING.md in its entirety
  • I have performed a self-review of my own code
  • I have added unit tests to cover my changes
  • The last commit successfully passed pre-commit checks
  • Any AI code was thoroughly reviewed by me

Summary by CodeRabbit

  • New Features
    • Expense details now show when a payer owes part of an expense and will receive money back, including the relevant amounts.
  • Style
    • Participant rows can wrap onto multiple lines for improved readability.

The payer's line now reads "owes X and gets back Y" instead of only
"gets Y", so every person's share is visible. Refunds, settlements and
currency conversions are unchanged. Long lines now wrap on narrow
screens.

Moves NON_SPENDING_SPLIT_TYPES to src/lib/splitTypes.ts so group
statistics and expense details share it.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Expense details now calculate and display a payer’s share for qualifying spending splits. The participant text and layout reflect the share, and tests cover the calculations and displayed amounts. Split type classification is now defined in splitTypes.ts.

Changes: Payer share display

Layer / File(s) Summary
Split classification and share calculation
src/lib/splitTypes.ts, src/lib/groupStatistics.ts, src/server/api/routers/group.ts, src/lib/expenseShare.ts, src/tests/expenseShare.test.ts
The non-spending split types move to splitTypes.ts, which adds a predicate for spending split types. New helpers determine when an expense has a share breakdown and calculate a participant’s share. Unit tests cover these helpers.
Expense participant display
src/components/Expense/ExpenseDetails.tsx, public/locales/en/common.json, tests/e2e/group-expense.spec.ts
Expense details pass the calculated payer share to the payer’s participant entry. When the payer share and participant amount are positive, the entry uses the new translation and displays the share. Participant rows can wrap. The end-to-end test checks the displayed amounts.

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

Change: Feature

Suggested reviewers: krokosik

Merge Risk: Minimal · up to d9ab9

The change adds the payer's own share to expense details and lets long lines wrap on narrow screens. No merge-blocking risk was identified. It is covered by unit and end-to-end tests.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat: show the payer's own share on expense details" matches the main change. The PR adds the payer's share to the payer's line on the expense details page ("owes X and gets back Y"). The t…
Description check Passed The description covers the required template sections. The Description section explains the change, the reason for it, and the scope, and it notes the related constant move. The Demo section has befor…
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.
Full details: Title check

Explanation

The title "feat: show the payer's own share on expense details" matches the main change. The PR adds the payer's share to the payer's line on the expense details page ("owes X and gets back Y"). The title is specific and concise. It omits the secondary changes (line wrapping and moving NON_SPENDING_SPLIT_TYPES), which is acceptable.

Full details: Description check

Explanation

The description covers the required template sections. The Description section explains the change, the reason for it, and the scope, and it notes the related constant move. The Demo section has before and after screenshots. The Testing section lists unit tests, the E2E update, and the integration test. The checklist is complete. The template's comment placeholders are filled in, and the description is detailed and specific. The description does not link a closing issue keyword. It references #807 only for group statistics queries, so the template's issue-link prompt is not clearly answered.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8922f931-9388-4dbd-8239-8f3316350356
Commits

Reviewing files that changed from the base of the PR and between 7f48b66 and d9ab9d3.

Files selected for processing: 8

  • public/locales/en/common.json
  • src/components/Expense/ExpenseDetails.tsx
  • src/lib/expenseShare.ts
  • src/lib/groupStatistics.ts
  • src/lib/splitTypes.ts
  • src/server/api/routers/group.ts
  • src/tests/expenseShare.test.ts
  • tests/e2e/group-expense.spec.ts
Files with no reviewable changes: 1

  • src/lib/groupStatistics.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
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.

1 participant