-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TS migration] Migrate StepScreenWrapper, StepScreenDragAndDropWrapper, IOURequestStepConfirmation and IOURequestStepCategory pages to TypeScript #39175
Conversation
@BrtqKr any updates here ? |
only some parts of |
src/libs/SidebarUtils.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'll check it during tests then, thank you
return React.forwardRef(WithCurrentUserPersonalDetails); | ||
return WithCurrentUserPersonalDetails; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might break a lot of components, I think forwardRef should stay here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover, in the end I used a hook, so there wouldn't be any type issues anyway
src/libs/actions/IOU.ts
Outdated
} | ||
|
||
/** Save the preferred payment method for a policy */ | ||
function savePreferredPaymentMethod(policyID: string, paymentMethod: PaymentMethodType) { | ||
Onyx.merge(`${ONYXKEYS.NVP_LAST_PAYMENT_METHOD}`, {[policyID]: paymentMethod}); | ||
} | ||
|
||
export type {GPSPoint as GpsPoint}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Add empty lines between props here
|
||
function IOURequestStepCategory({ | ||
report, | ||
stackProps: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use stackProps anywhere in the project, let's use route
as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it added by mistake? Or extracted from another file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An in other places too, just be careful and let's test the component thoroughly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not remove comments for props
report: reportPropTypes, | ||
type IOURequestStepConfirmationProps = IOURequestStepConfirmationOnyxProps & | ||
WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_CONFIRMATION> & { | ||
transaction: OnyxEntry<Transaction>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
personalDetails: { | ||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go ahead and remove personalDetails from here, instead use useCurrentUserPersonalDetails hook, this should do the trick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ? |
Reviewer Checklist
Screenshots/VideosAndroid: NativeCleanShot.2024-04-08.at.07.27.22.mp4CleanShot.2024-04-08.at.07.29.14.mp4Android: mWeb ChromeScreen.Recording.2024-04-08.at.7.33.57.AM.moviOS: NativeCleanShot.2024-04-08.at.07.03.22.mp4CleanShot.2024-04-08.at.07.04.43.mp4iOS: mWeb SafariCleanShot.2024-04-08.at.07.08.58.mp4MacOS: Chrome / SafariCleanShot.2024-04-08.at.00.15.19.mp4CleanShot.2024-04-08.at.00.17.40.mp4MacOS: DesktopCleanShot.2024-04-08.at.06.34.06.mp4CleanShot.2024-04-08.at.06.35.32.mp4CleanShot.2024-04-08.at.06.37.08.mp4 |
StepScreenWrapper.defaultProps = defaultProps; | ||
|
||
export default StepScreenWrapper; | ||
export default forwardRef(StepScreenWrapper); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 🚀
|
Details
Fixed Issues
$ #38918
$ #38913
PROPOSAL:
Tests
Offline tests
QA Steps
Same as in Tests/Offline tests section
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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