Repository navigation
Fix inline category edit not saving on the first attempt - #99178
Conversation
|
@bernhardoj Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
This PR adds a new |
On Search surfaces useOnyx resolves a transaction_<id> read against the search snapshot, but getUpdateMoneyRequestParams read the live TRANSACTION collection, which has no entry for a row the user has not opened. The transaction came back undefined, dataToIncludeInParams came out empty, and UpdateMoneyRequestCategory went out with no category field, clearing any category the expense already had. Pass the transaction the hook already holds down to the write and keep the cache lookup as the fallback so other callers are unaffected.
Resolving the caller's copy first let a render-time transaction win even when the live TRANSACTION collection had a fresher entry. That matters because the optimistic update merges the whole resolved transaction back into the live Onyx key, so a stale copy would overwrite live fields. The live lookup returns undefined for the Search rows this fixes, so the behaviour there is unchanged. Also pass the transaction in the existing inline-edit test now that the param is required, and drop an unsafe cast and a promise-executor return in the new regression test.
|
There are no more connectWithoutView references so I'm dropping the reviewers for it. |
|
Since this issue happens on other inline edit fields too, let's apply the fix to all |
Only the category edit forwarded the caller's transaction, so date, merchant, description, amount and tag still resolved it from the live TRANSACTION collection and went out missing their field on a Search row the user had not opened. All six now forward it, and the param wins over the cache lookup, which stays as the fallback for the callers that pass only a transactionID. getIouParamsForTransaction takes the transaction directly: it is a required param and the only caller is the inline edit hook, so the cache lookup was dead code. Two related failures fixed by the same threading: - isValidMerchant only permits an empty merchant on an unreported expense, which it reads off the transaction. Without one, clearing a merchant was discarded before any API call. - getUpdateTrackExpenseParams repeated the same lookup, so date, merchant, description and amount edits on a self-DM expense stayed broken even once the other path was fixed. Its currency context now carries the transaction too.
Moves the category regression test into TransactionInlineEdit.test.ts and widens it to all six fields, each asserting its delegate receives the forwarded transaction. Adds a case for clearing a merchant, which was previously dropped before the API call. The delegates are mocked rather than the API layer: editTransaction*Inline only builds params and calls through, so that boundary is the assertion point. That also removes the need for Onyx setup, since an uninitialised transaction cache is exactly the state being tested.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Applied to all |
cspell flagged "initialised" in the CI spell check.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safariweb.mp4 |
There was a problem hiding this comment.
Small suggestion left.
Going to approve for now, @mukhrr but please look at the suggestions.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.60-0 🚀
|
|
🤖 I reviewed this PR against the help site articles in Why: This is an internal bug fix, not a behavior or feature change. It threads the The existing article Edit Expenses already documents this exact behavior accurately:
Since the docs already reflect the correct (intended) behavior that this PR restores, there is nothing to update. There is no linked help site PR to review — none was needed for this change. |
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.4.60-2 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
On Search,
useOnyxreads the transaction from the search snapshot, but the action layer looked it up again in the liveTRANSACTIONcollection, which has no entry for a row the user has not opened.transactioncame back undefined, sodataToIncludeInParamswas empty and the write went out with no edited field, clearing any value the expense already had.Every
editTransaction*Inlinefield now forwards the transaction the hook already holds.getIouParamsForTransactionuses it directly, since it is a required param and the cache lookup was dead code.getUpdateMoneyRequestParamsandgetUpdateTrackExpenseParamsprefer it and keep the lookup as the fallback, so callers that pass only atransactionIDare unchanged.Two related failures the widening exposed:
isValidMerchantonly allows an empty merchant on an unreported expense, which it reads off the transaction. Without one, clearing a merchant was discarded before any API call.getUpdateTrackExpenseParamsrepeats the same lookup, and date, merchant, description and amount on a self-DM expense route through it, so they stayed broken until it was threaded too.Fixed Issues
$ #98403
PROPOSAL: #98403 (comment)
Tests
UpdateMoneyRequest*request payload carries the edited field.Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
web.mp4