[No QA] Refactor TransactionDraft selectors into dedicated hooks#82790
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
203fbd7 to
79cf84c
Compare
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
No product review needed |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
Everything is looking good, but I have a question @TMisiukiewicz: are we not violating the PERF-11 rule by not using selectors inside these hooks? Or am I missing something? Thank you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71ca6ab3a9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@brunovjk both selectors subscribe to a collection without a selector and transform inline, which is the exact correct pattern per PERF-11. If it was a selector, it would make things worse - Onyx would use |
Great! Thank you for clarifying |
| function useTransactionDraftValues(): Array<Transaction | null | undefined> { | ||
| const [drafts] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {canBeMissing: true}); | ||
|
|
||
| return Object.values(drafts ?? {}); | ||
| } |
There was a problem hiding this comment.
I think this muddies not quite a lot the sort of guidance for when and where to use the selectors or not. do you have some clear guidance shaping up now based on your measurements?
|
🚧 @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! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.24-1 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.3.24-3 🚀
|
Explanation of Change
Removed the
TransactionDraft.tsselector file and replaced its three selector functions with two dedicated hooks:useTransactionDraftValuesanduseTransactionDraftReceipts. The receipts hook uses a single-passreduceinstead of the previousmap+filterchain for better efficiency. All consumers (useOptimisticDraftTransactions,MoneyRequestParticipantsSelector,ReceiptPreviews,ReceiptView) now call these hooks directly, eliminating the need to wire upuseOnyxwith a selector at every call site. Unit tests were added for both new hooks.Fixed Issues
$ #82645
PROPOSAL:
Tests
No tests needed - just a refactor
Offline tests
N/A
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