[TS migration] Migrate StepScreenWrapper, StepScreenDragAndDropWrapper, IOURequestStepConfirmation and IOURequestStepCategory pages to TypeScript#39175
Conversation
|
@BrtqKr any updates here ? |
only some parts of |
| alternateText: null, | ||
| alternateText: undefined, | ||
| allReportErrors: OptionsListUtils.getAllReportErrors(report, reportActions), | ||
| brickRoadIndicator: null, | ||
| tooltipText: null, | ||
| subtitle: null, | ||
| login: null, | ||
| accountID: null, | ||
| login: undefined, | ||
| accountID: undefined, | ||
| reportID: '', | ||
| phoneNumber: null, | ||
| phoneNumber: undefined, | ||
| isUnread: null, | ||
| isUnreadWithMention: null, | ||
| hasDraftComment: false, | ||
| keyForList: null, | ||
| searchText: null, | ||
| keyForList: undefined, | ||
| searchText: undefined, |
There was a problem hiding this comment.
@kubabutkiewicz from what I've seen you've been working on that part, was it necessary for everything in here to be marked as null? It's been causing conflicts with Participant type and since it had to be used as Participant | OptionData because of this:
const participants = useMemo(
() =>
transaction?.participants?.map((participant) => {
const participantAccountID = participant.accountID ?? 0;
return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant);
}),
[transaction?.participants, personalDetails],
);
null and undefined discrepancy wouldn't allow this to go through. Additionally I don't see any places where this is checked for null explicitly
There was a problem hiding this comment.
I am not sure 100%, but I think the null's was there when I started to work on that and I just left it
There was a problem hiding this comment.
ok, I'll check it during tests then, thank you
| WithCurrentUserPersonalDetails.displayName = `WithCurrentUserPersonalDetails(${getComponentDisplayName(WrappedComponent)})`; | ||
|
|
||
| return React.forwardRef(WithCurrentUserPersonalDetails); | ||
| return WithCurrentUserPersonalDetails; |
There was a problem hiding this comment.
This might break a lot of components, I think forwardRef should stay here
There was a problem hiding this comment.
leftover, in the end I used a hook, so there wouldn't be any type issues anyway
src/libs/actions/IOU.ts
Outdated
| Onyx.merge(`${ONYXKEYS.NVP_LAST_PAYMENT_METHOD}`, {[policyID]: paymentMethod}); | ||
| } | ||
|
|
||
| export type {GPSPoint as GpsPoint}; |
There was a problem hiding this comment.
It's used in two separate places and the other type originating from coords has many more fields, which aren't optional, so we probably want to avoid applying it. I can still define this type inline though, up to you 🤷
| /** The draft transaction that holds data to be persisted on the current transaction */ | ||
| splitDraftTransaction: OnyxEntry<Transaction>; | ||
| /** The policy of the report */ | ||
| policy: OnyxEntry<Policy>; | ||
| /** Collection of categories attached to a policy */ | ||
| policyCategories: OnyxEntry<PolicyCategories>; | ||
| /** Collection of tags attached to a policy */ | ||
| policyTags: OnyxEntry<PolicyTagList>; | ||
| /** The actions from the parent report */ | ||
| reportActions: OnyxEntry<ReportActions>; | ||
| /** Session info for the currently logged in user. */ | ||
| session: OnyxEntry<Session>; |
There was a problem hiding this comment.
Nit: Add empty lines between props here
|
|
||
| function IOURequestStepCategory({ | ||
| report, | ||
| stackProps: { |
There was a problem hiding this comment.
We don't use stackProps anywhere in the project, let's use route as before
There was a problem hiding this comment.
Also you might face the problem described here, please have a look
| const IOURequestStepCategoryWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepCategory); | ||
| /* eslint-disable rulesdir/no-negated-variables */ | ||
| const IOURequestStepCategoryWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepCategoryWithWritableReportOrNotFound); | ||
| export default withOnyx<IOURequestStepCategoryProps, IOURequestStepCategoryOnyxProps>({ |
There was a problem hiding this comment.
The order of hocs have changed a(b(c())) -> c(b(a())). This might break the component in very unexpected ways 😅
Here is how Marcin did it in other PR
There was a problem hiding this comment.
Was it added by mistake? Or extracted from another file?
There was a problem hiding this comment.
I changed some of the IOU utils to accept named params, but in the meantime, someone removed this whole file. I already got rid of it
| const IOURequestStepConfirmationWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepConfirmation); | ||
| /* eslint-disable rulesdir/no-negated-variables */ | ||
| const IOURequestStepConfirmationWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepConfirmationWithWritableReportOrNotFound); | ||
| export default withOnyx<IOURequestStepConfirmationProps, IOURequestStepConfirmationOnyxProps>({ |
| const isEditingSplitBill = isEditing && iouType === CONST.IOU.TYPE.SPLIT; | ||
| const transactionCategory = ReportUtils.getTransactionDetails(isEditingSplitBill && !lodashIsEmpty(splitDraftTransaction) ? splitDraftTransaction : transaction)?.category; | ||
|
|
||
| const reportAction = reportActions?.[report?.parentReportActionID ?? reportActionID] ?? null; |
There was a problem hiding this comment.
Just saying: ?? instead of || might change the logic a bit, you might have to use eslint disable comment.
There was a problem hiding this comment.
An in other places too, just be careful and let's test the component thoroughly
There was a problem hiding this comment.
it didn't seem to break this, but I don't want to risk breaking anything, I'll leave it as it was
| policy: OnyxEntry<Policy>; | ||
| policyCategories: OnyxEntry<PolicyCategories>; | ||
| policyTags: OnyxEntry<PolicyTagList>; | ||
| personalDetails: OnyxEntry<PersonalDetailsList>; |
There was a problem hiding this comment.
Let's not remove comments for props
| report: reportPropTypes, | ||
| type IOURequestStepConfirmationProps = IOURequestStepConfirmationOnyxProps & | ||
| WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_CONFIRMATION> & { | ||
| transaction: OnyxEntry<Transaction>; |
| personalDetails: { | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| }, |
There was a problem hiding this comment.
Go ahead and remove personalDetails from here, instead use useCurrentUserPersonalDetails hook, this should do the trick
There was a problem hiding this comment.
it has already been removed on the main, so it got resolved during the branch update
|
Also typecheck is failing @BrtqKr |
|
Any updates here @BrtqKr ? |
| StepScreenWrapper.defaultProps = defaultProps; | ||
|
|
||
| export default StepScreenWrapper; | ||
| export default forwardRef(StepScreenWrapper); |
There was a problem hiding this comment.
| export default forwardRef(StepScreenWrapper); | |
| StepScreenWrapper.displayName = 'StepScreenWrapper'; | |
| export default StepScreenWrapper; |
Why do we use forwardRef in this component?
There was a problem hiding this comment.
For some reason, when I was working on that, the steps where throwing errors during render attempt, but it might have been fixed when I changed the callOrReturn content. I already removed it
|
Bug: Cannot request money from new users (whom you have not chatted with before)
Screen.Recording.2024-04-08.at.5.10.10.PM.movThis is how it works on staging Screen.Recording.2024-04-08.at.5.14.13.PM.mov |
|
@fedirjh I ran this reproduction and it seems to be working as expected. If there are any steps I need to include, that are not present in the recording, please let me know Screen.Recording.2024-04-09.at.11.49.58.mov |
@BrtqKr It seems you have tested the split flow. However, the bug occurs with the request flow. CleanShot.2024-04-09.at.15.16.52.mp4 |
| if (!report || !transaction) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
| if (!report || !transaction) { | |
| return; | |
| } | |
| if (!transaction) { | |
| return; | |
| } |
@BrtqKr This line is causing the bug in #39175 (comment) . We should allow creation of money requests when the report is not yet created.
fedirjh
left a comment
There was a problem hiding this comment.
Looks good to me and tests well 🚀
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #38918 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
✋ 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/aldo-expensify in version: 1.4.62-0 🚀
|
1 similar comment
|
🚀 Deployed to staging by https://github.com/aldo-expensify in version: 1.4.62-0 🚀
|
|
🚀 Deployed to staging by https://github.com/aldo-expensify in version: 1.4.62-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.62-17 🚀
|
| <StepScreenWrapper | ||
| headerTitle={translate('common.category')} | ||
| onBackButtonPress={navigateBack} | ||
| shouldShowWrapper | ||
| shouldShowNotFoundPage={shouldShowNotFoundPage} | ||
| testID={IOURequestStepCategory.displayName} | ||
| includeSafeAreaPaddingBottom={false} | ||
| > |
There was a problem hiding this comment.
Because StepScreenWrapper has shouldEnableKeyboardAvoidingView set to true by default (when not passed), this led to the following issue:
which we addressed by passing shouldEnableKeyboardAvoidingView={false} in order to disable the keyboard avoiding view.

Details
Fixed Issues
$ #38918
$ #38913
PROPOSAL:
Tests
Offline tests
QA Steps
Same as in Tests/Offline tests section
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.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
Screen.Recording.2024-04-03.at.17.59.24.mov
Android: mWeb Chrome
Screen.Recording.2024-04-04.at.10.32.24.mov
iOS: Native
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-04-03.at.17.38.41.mp4
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-04-03.at.18.46.31.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-04-04.at.10.56.39.mov
MacOS: Desktop
Screen.Recording.2024-04-04.at.10.40.11.mov