Fix emoji reaction removal crash after hex-key migration#95664
Draft
roryabraham wants to merge 5 commits into
Draft
Fix emoji reaction removal crash after hex-key migration#95664roryabraham wants to merge 5 commits into
roryabraham wants to merge 5 commits into
Conversation
Adds a regression test that reproduces the TypeError thrown by toggleEmojiReaction when a legacy name-keyed reaction stub (left behind without a `users` field) coexists with a hex-keyed reaction, which is the Onyx shape produced once Auth writes emoji reactions under hex keys. Co-authored-by: Cursor <cursoragent@cursor.com>
toggleEmojiReaction crashed when a reaction entry existed without a `users` field (e.g. a legacy name-keyed stub left behind after Auth NILs it post hex-key migration). Guard both the call sites and hasAccountIDEmojiReacted itself so a partial reaction entry is treated as "no reaction" instead of throwing. Co-authored-by: Cursor <cursoragent@cursor.com>
Asserts that addEmojiReaction's finallyData NILs the optimistic name-keyed entry and clears pendingAction on the canonical hex key, instead of recreating a name-key stub after the server has already merged the hex-keyed reaction into Onyx. Co-authored-by: Cursor <cursoragent@cursor.com>
Auth now stores emoji reactions under canonical hexcodes and clears legacy name-keyed entries in its Onyx response. addEmojiReaction's finallyData still cleared pendingAction on the name key only, which recreated a name-key stub (with no `users`) right after the server had already NILed it, corrupting Onyx and crashing removal. Now the name key is NILed and pendingAction is cleared on the hex key instead, matching Auth's post-response Onyx shape. Co-authored-by: Cursor <cursoragent@cursor.com>
Reworks the two new regression tests to stay within eslint-seatbelt's budget for unsafe type assertions and to satisfy the strict ReportActionReaction type: builds the name-key stub with a fully typed object and removes its `users` field via Reflect.deleteProperty instead of an untyped literal, and asserts on write() calls with toHaveBeenCalledWith/objectContaining instead of casting the mock's call arguments. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Explanation of Change
Auth#22634 migrates emoji reactions to be stored under canonical hex-codes (e.g.
1F604) and NIL-merges the legacy name-keyed entry (e.g.smile) in its Onyx response. App still writes its optimistic/finally Onyx updates under the name key, soaddEmojiReaction'sfinallyDatawas re-creating a name-keyed stub ({pendingAction: null}, with nousers) right after the server had already cleared it.toggleEmojiReactionthen crashed withTypeError: Cannot read properties of undefined (reading '<accountID>')when it tried to read.usersoff that stub while deciding whether to add or remove a reaction.This PR is an App-only fix:
addEmojiReaction'sfinallyDatanow NILs the optimistic name key and clearspendingActionon the canonical hex key instead, so it doesn't undo the server's Onyx merge.toggleEmojiReactionandhasAccountIDEmojiReactednow guard against a reaction entry that is missingusers, so any lingering partial entry is treated as "no reaction" rather than throwing.Fixed Issues
$ https://github.com/Expensify/Expensify/issues/504276
PROPOSAL:
Companion backend change: Auth#22634
Tests
TypeErrorappears in the JS console.npm run test -- EmojiReactionsTestand confirm all tests pass.Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari