refactor: buildOnyxDataForInvoice to use a parameter object.#57294
refactor: buildOnyxDataForInvoice to use a parameter object.#57294neil-marcellini merged 9 commits intoExpensify:mainfrom
Conversation
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
@dominictb 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] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-02-23.at.22.07.54.movAndroid: mWeb ChromeScreen.Recording.2025-02-23.at.20.56.49.moviOS: NativeScreen.Recording.2025-02-23.at.21.24.22.moviOS: mWeb SafariScreen.Recording.2025-02-23.at.20.55.19.movMacOS: Chrome / SafariScreen.Recording.2025-02-23.at.20.50.48.movMacOS: DesktopScreen.Recording.2025-02-23.at.21.02.11.mov |
|
I faced some issues while building Android App, will record soon |
| type BuildOnyxDataForInvoiceParams = { | ||
| chatReport: OnyxEntry<OnyxTypes.Report>; | ||
| iouReport: OnyxTypes.Report; | ||
| transaction: OnyxTypes.Transaction; | ||
| chatCreatedAction: OptimisticCreatedReportAction; | ||
| iouCreatedAction: OptimisticCreatedReportAction; | ||
| iouAction: OptimisticIOUReportAction; | ||
| optimisticPersonalDetailListAction: OnyxTypes.PersonalDetailsList; | ||
| reportPreviewAction: ReportAction; | ||
| optimisticPolicyRecentlyUsedCategories: string[]; | ||
| optimisticPolicyRecentlyUsedTags: OnyxTypes.RecentlyUsedTags; | ||
| isNewChatReport: boolean; | ||
| transactionThreadReport: OptimisticChatReport; | ||
| transactionThreadCreatedReportAction: OptimisticCreatedReportAction | null; | ||
| policy?: OnyxEntry<OnyxTypes.Policy>; | ||
| policyTagList?: OnyxEntry<OnyxTypes.PolicyTagLists>; | ||
| policyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>; | ||
| optimisticRecentlyUsedCurrencies?: string[]; | ||
| companyName?: string; | ||
| companyWebsite?: string; | ||
| }; |
There was a problem hiding this comment.
Can we please group together all chat, iou, policy, etc, related params like we do for MoneyRequestOptimisticParams?
There was a problem hiding this comment.
@dominictb, I have regrouped the params, could you please look at it once? Thanks!
…ceParams. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
src/libs/actions/IOU.ts
Outdated
| transactionThreadReport: OptimisticChatReport; | ||
| transactionThreadCreatedReportAction: OptimisticCreatedReportAction | null; | ||
| }; | ||
| policyParams: { |
There was a problem hiding this comment.
I think we should use RequestMoneyPolicyParams for policyParams and create new type for optimisticData
|
@Krishna2323 Almost done, I left 1 minor comment only |
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
| type BuildOnyxDataForInvoiceParams = { | ||
| chat: { | ||
| chatReport: OnyxEntry<OnyxTypes.Report>; | ||
| chatCreatedAction: OptimisticCreatedReportAction; | ||
| reportPreviewAction: ReportAction; | ||
| isNewChatReport: boolean; | ||
| }; | ||
| iou: { | ||
| iouCreatedAction: OptimisticCreatedReportAction; | ||
| iouAction: OptimisticIOUReportAction; | ||
| iouReport: OnyxTypes.Report; | ||
| }; | ||
| transactionParams: { | ||
| transaction: OnyxTypes.Transaction; | ||
| transactionThreadReport: OptimisticChatReport; | ||
| transactionThreadCreatedReportAction: OptimisticCreatedReportAction | null; | ||
| }; | ||
| policyParams: RequestMoneyPolicyParams; | ||
| optimisticData: { | ||
| optimisticRecentlyUsedCurrencies?: string[]; | ||
| optimisticPolicyRecentlyUsedCategories: string[]; | ||
| optimisticPolicyRecentlyUsedTags: OnyxTypes.RecentlyUsedTags; | ||
| optimisticPersonalDetailListAction: OnyxTypes.PersonalDetailsList; | ||
| }; | ||
| companyName?: string; | ||
| companyWebsite?: string; | ||
| }; |
There was a problem hiding this comment.
Looks good, but please remove the redundant prefixes in the sub-objects. It's redundant to have to write iou.iouSomeFieldName. For example, like we have here
Lines 399 to 403 in 78a4032
There was a problem hiding this comment.
@neil-marcellini, I removed the prefixes, but what’s the correct way to access the nested value? Should we use iou.iouCreatedAction.reportActionID, or destructuring is preferred?
I have implemented it using destructuring. Could you please confirm if this is correct? Thanks!
const {
chat: {report: chatReport, createdAction: chatCreatedAction, reportPreviewAction, isNewReport: isNewChatReport},
iou: {createdAction: iouCreatedAction, action: iouAction, report: iouReport},
transactionParams: {transaction, threadReport: transactionThreadReport, threadCreatedReportAction: transactionThreadCreatedReportAction},
policyParams: {policy, policyTagList, policyCategories},
optimisticData: {
policyRecentlyUsedCategories: optimisticPolicyRecentlyUsedCategories,
policyRecentlyUsedTags: optimisticPolicyRecentlyUsedTags,
personalDetailListAction: optimisticPersonalDetailListAction,
recentlyUsedCurrencies: optimisticRecentlyUsedCurrencies,
},
companyName,
companyWebsite,
} = invoiceParams;There was a problem hiding this comment.
I think I prefer doing it without de-structuring iou.createdAction.reportActionID because then it's less redundant. However, I have allowed it with de-structuring before and it does have the advantage that you don't have to update all the places these variables are used.
If you would please update it to use dot notation I would appreciate that and I think it sets a good standard moving forward. Part of the goal of this refactor is to reduce the large number of variables to manage, and have a small number of object variables that are well organized and documented by their types.
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
neil-marcellini
left a comment
There was a problem hiding this comment.
Thanks for the update. It looks good as is, but there are conflicts. So while you resolve those please also update it to use dot notation to access param fields. Thanks for sticking with this one.
|
Please DM me when you get it updated and I can review quickly if I'm online |
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…iceParams. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
neil-marcellini
left a comment
There was a problem hiding this comment.
Great, thank you!
|
✋ 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/neil-marcellini in version: 9.1.7-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.1.7-2 🚀
|
Explanation of Change
Fixed Issues
$ #57256
PROPOSAL: #57256 (comment)
Tests
invoicesenabled.Send invoice> Enter amountSend invoiceOffline tests
invoicesenabled.Send invoice> Enter amountSend invoiceQA Steps
invoicesenabled.Send invoice> Enter amountSend invoicePR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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_native.mp4
Android: mWeb Chrome
android_chrome.mp4
iOS: Native
ios_native.mp4
iOS: mWeb Safari
ios_safari.mp4
MacOS: Chrome / Safari
web_chrome.mp4
MacOS: Desktop
desktop_app.mp4