fix(client): stop shared items counting towards the recipient bag weight

An item shared through the sharing tier is visible to its recipients but
carried by its owner. The bag totals filtered on bag_id alone, so every
recipient saw the owner's weight added to their own load — which is exactly
the situation that tier exists for (one person brings the first-aid kit).

Filtering by owner_id, as the issue suggests, would have broken more than it
fixed: owner_id is stamped on every item including Common ones, so the group
pool would have shrunk to "only what I entered myself" even on trips where
nobody shares anything. The predicate keeps the Common pool intact and drops
only private items owned by someone else.

Closes #1767
This commit is contained in:
Maurice
2026-08-03 21:47:45 +02:00
committed by Maurice
parent d7d7fac339
commit 446bbdc38f
7 changed files with 111 additions and 19 deletions
@@ -14,6 +14,22 @@ export function katColor(kat: string, allCategories?: string[]): string {
export const itemWeight = (i: { weight_grams?: number | null; quantity?: number | null }): number =>
(i.weight_grams || 0) * (i.quantity || 1)
/**
* Whether an item's weight is part of what *you* carry. An item shared through the
* "Shared with…" tier stays visible to its recipients, but the owner is the one bringing
* it — counting it for everyone it was shared with inflated their bags (#1767).
* Common items are the group pool and always count; so does anything unowned (legacy
* rows) and everything, if we don't know who is looking.
*/
export const countsTowardsMyLoad = (
i: { is_private?: number | boolean | null; owner_id?: number | null },
currentUserId?: number | null,
): boolean => {
if (currentUserId == null) return true
if (!i.is_private) return true
return i.owner_id == null || i.owner_id === currentUserId
}
/**
* How full a bag's bar reads. A bag with a weight limit is measured against that limit —
* that is the number an airline cares about. Without one there is nothing absolute to