[TS migration] Migrate 'MoneyRequestConfirmationList.js' component to TypeScript#37716
Conversation
…s-migration/MoneyRequestConfirmationList/component
…s-migration/MoneyRequestConfirmationList/component
|
|
||
| const {image: receiptImage, thumbnail: receiptThumbnail} = | ||
| props.receiptPath && props.receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, props.receiptPath, props.receiptFilename) : {}; | ||
| receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); |
There was a problem hiding this comment.
You can simplify it if you want
const receipt = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : null;
const receiptImage = receipt?.image;
const receiptThumbnail = receipt?.thumbnail;
src/libs/ReceiptUtils.ts
Outdated
| * @param receiptFileName | ||
| */ | ||
| function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction>, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { | ||
| function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction> | undefined, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { |
There was a problem hiding this comment.
I think you can pass null instead of undefined to keep typing easier. To simplify you can add null as a default value in MoneyRequestConfirmationList. What do you think?
| function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction> | undefined, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { | |
| function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction>, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { |
There was a problem hiding this comment.
At the beginning I did that but then I realised I need to do it in a lot of places and decided that adding undefined to this type will be more readable
src/libs/TransactionUtils.ts
Outdated
|
|
||
| function isMerchantMissing(transaction: Transaction) { | ||
| if (transaction.modifiedMerchant && transaction.modifiedMerchant !== '') { | ||
| function isMerchantMissing(transaction: OnyxEntry<Transaction> | undefined) { |
There was a problem hiding this comment.
Same for every | undefined update in this file
There was a problem hiding this comment.
I agree, could we avoid this?
| onPress={(_event, value) => confirm(value as PaymentMethodType)} | ||
| options={splitOrRequestOptions} |
There was a problem hiding this comment.
Since ButtonWithDropdownMenu has genric in typing, you can try to update splitOrRequestOptions typing to include PaymentMethodType instead of string. Though iouType and PaymentMethodType are not aligned, so there will be another TS problem.
There was a problem hiding this comment.
I ended up typing confirm fn to by IouType | PaymentMethodType | undefined since I check and here from value we can only IouType based on implementation of splitOrRequestOptions but looking and implementation of sendMoney which is called inside confirm, sendMoney expects that the type will be PaymentMethodType which is odd since from my understanding it will never happen here
…s-migration/MoneyRequestConfirmationList/component
src/libs/TransactionUtils.ts
Outdated
|
|
||
| function isMerchantMissing(transaction: Transaction) { | ||
| if (transaction.modifiedMerchant && transaction.modifiedMerchant !== '') { | ||
| function isMerchantMissing(transaction: OnyxEntry<Transaction> | undefined) { |
There was a problem hiding this comment.
I agree, could we avoid this?
|
|
||
| const {image: receiptImage, thumbnail: receiptThumbnail} = | ||
| props.receiptPath && props.receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, props.receiptPath, props.receiptFilename) : {}; | ||
| receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction ?? null, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); |
There was a problem hiding this comment.
You decided to skip this comment or is it just lost?
There was a problem hiding this comment.
I decided to skip it I think its fine to leave it as it was
| formattedParticipantsList = formattedParticipantsList.map((participant) => ({ | ||
| ...participant, | ||
| isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID), | ||
| isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1), |
There was a problem hiding this comment.
Should we modify ReportUtils.isOptimisticPersonalDetail to allow either number or undefined, then early exit if it's undefined there? Use a default value here doesn't look good to me.
| const formattedSelectedParticipants = selectedParticipantsProp.map((participant) => ({ | ||
| ...participant, | ||
| isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID), | ||
| isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1), |
| return; | ||
| } | ||
| Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID)); | ||
| Navigation.navigate( |
There was a problem hiding this comment.
Are we missing moving condition isEditingSplitBill from old component?
|
Hi @fedirjh, This PR comes from here #25138 (comment). Let @kubabutkiewicz and me continue to work on it. Thanks |
…s-migration/MoneyRequestConfirmationList/component
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-03-12.at.19.16.22.android.movAndroid: mWeb ChromeScreen.Recording.2024-03-12.at.18.41.45.android.chrome.moviOS: NativeScreen.Recording.2024-03-12.at.19.19.39.ios.moviOS: mWeb SafariScreen.Recording.2024-03-12.at.19.21.49.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2024-03-12.at.07.23.43.web.mp4MacOS: DesktopScreen.Recording.2024-03-12.at.18.36.03.desktop.mov |
hoangzinh
left a comment
There was a problem hiding this comment.
LGTM. Tested on:
- Send money
- Split bill with a WS
- Split bill with an individual user
|
✋ 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/AndrewGable in version: 1.4.51-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.51-3 🚀
|

Details
Fixed Issues
$ #25138
Tests
Login to app
Click on FAB icon
Select Send Money
Go through all steps for sending money
Verify all is working
Login to app
Click on FAB icon
Select Money Request
When selecting user click on Split button
Finish that process
Click on Split report to open confirmation list
Verify it look and work well
Login to app
To go Workspace chat
Click '+' icon
Select Split Bill
Select scan option
Go through this process
Verify that everything look and work well
Offline tests
QA Steps
Login to app
Click on FAB icon
Select Send Money
Go through all steps for sending money
Verify all is working
Login to app
Click on FAB icon
Select Money Request
When selecting user click on Split button
Finish that process
Click on Split report to open confirmation list
Verify it look and work well
Login to app
To go Workspace chat
Click '+' icon
Select Split Bill
Select scan option
Go through this process
Verify that everything look and work well
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.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 so 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.mp4
Android: mWeb Chrome
mchrome.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
msafari.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4