fix: prevent user/group ID collision in currency preference store#662
Open
jaredslorenz wants to merge 3 commits into
Open
fix: prevent user/group ID collision in currency preference store#662jaredslorenz wants to merge 3 commits into
jaredslorenz wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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