Skip to content

fix: prevent user/group ID collision in currency preference store#662

Open
jaredslorenz wants to merge 3 commits into
oss-apps:mainfrom
jaredslorenz:fix/currency-state-collision
Open

fix: prevent user/group ID collision in currency preference store#662
jaredslorenz wants to merge 3 commits into
oss-apps:mainfrom
jaredslorenz:fix/currency-state-collision

Conversation

@jaredslorenz
Copy link
Copy Markdown

Description

Closes #661
Integer ID collision between user IDs and group IDs in currencyPreferenceStore caused friend balances to display in the wrong currency after tab navigation. The getPreference function's fallback chain checked groupDefaultCurrencies for any numeric key — so if a user's ID matched a group ID with USD as its default, navigating to the Groups tab would poison the store and convert that user's EUR balance to USD on re-render.
Changes:

currencyPreferenceStore.ts — getPreference now takes entityType?: 'group'; group currencies only consulted when entityType === 'group'
ConvertibleBalance.tsx — Added entityType?: 'group' prop; gates group currency lookup accordingly
CumulatedBalances.tsx — Forwards entityType prop through to ConvertibleBalance
GroupMyBalance.tsx — Passes entityType="group" as the only correct caller for group currency defaulting

AI assistance was used to help diagnose the root cause and implement the fix. All changes were thoroughly reviewed by me before submission.

Demo

Unable to reproduce locally without the specific user data, but the fix is verified by code analysis and unit tests covering the exact collision scenario.

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

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.

Balance displays in USD instead of EUR for specific user after tab navigation

1 participant