-
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 'ReportUtils.js' lib to TypeScript #29012
[TS Migration] Migrate 'ReportUtils.js' lib to TypeScript #29012
Conversation
…s-migration/ReportUtils-lib
…s-migration/ReportUtils-lib
The problem is that Applause will take couple days and in the meantime there will be bunch of deploy blockers, I think with this kind of PR we need to bite the bullet and get it merged and fix on main/ staging as people notice some issues. |
Ok then |
@nkuoch all yours 🙏 |
src/libs/ReportUtils.ts
Outdated
}); | ||
} | ||
|
||
function isReportDraft(report: OnyxEntry<Report>): boolean { | ||
return isExpenseReport(report) && report?.stateNum === CONST.REPORT.STATE_NUM.OPEN && report.statusNum === CONST.REPORT.STATUS.OPEN; |
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.
return isExpenseReport(report) && report?.stateNum === CONST.REPORT.STATE_NUM.OPEN && report.statusNum === CONST.REPORT.STATUS.OPEN; | |
return isExpenseReport(report) && report.stateNum === CONST.REPORT.STATE_NUM.OPEN && report.statusNum === CONST.REPORT.STATUS.OPEN; |
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.
@nkuoch we need to have optional chaining here because report could be 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.
isExpenseReport is already making sure report is not null ... but I guess lint is complaining if you don't?
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.
Yeah , thats true
I think in this case it's better to have an ad hoc build tested for this and handle conflicts as they come. If we merge this PR and there are blockers, it's likely that a revert won't be easy because of conflicts and then we'd be blocking the deploy until we fix all issues. |
…s-migration/ReportUtils-lib
@nkuoch done, could you recheck? 🙏 |
…s-migration/ReportUtils-lib
@nkuoch conflicts resolved 🙏 |
✋ 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/nkuoch in version: 1.4.4-0 🚀
|
Hi @kubabutkiewicz , this migration generated this issue: #32111 |
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.4-3 🚀
|
const longName = personalDetails.displayName ? personalDetails.displayName : formattedLogin; | ||
|
||
const shortName = personalDetails.firstName ? personalDetails.firstName : longName; |
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 I saw you tried the optional chaining first: personalDetails.displayName ?? formattedLogin
. Was there any issue with using that approach? I suppose it showed the empty line if personalDetails.displayName
was such?
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.
Empty strings will create problems.
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 there any drawback to using just const longName = personalDetails.displayName || formattedLogin
?
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 not allowed on strings
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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.
Correct in js, but will throw type errors in ts
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.
Thanks. I didn't know it was a TS-specific thing 👍
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 think I am not needed here any more 😄 Thanks @shubham1206agra
return lodashGet(allPolicies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'avatar']) || getDefaultWorkspaceAvatar(workspaceName); | ||
function getWorkspaceAvatar(report: OnyxEntry<Report>): UserUtils.AvatarSource { | ||
const workspaceName = getPolicyName(report, false, allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]); | ||
return allPolicies?.[`policy${report?.policyID}`]?.avatar ?? getDefaultWorkspaceAvatar(workspaceName); |
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 was overlooked. ONYXKEYS.COLLECTION.POLICY
= policy_
(_ at the end) so below is the correct change:
return allPolicies?.[`policy${report?.policyID}`]?.avatar ?? getDefaultWorkspaceAvatar(workspaceName); | |
return allPolicies?.[`policy_${report?.policyID}`]?.avatar ?? getDefaultWorkspaceAvatar(workspaceName); |
As this is still within regression period, @kubabutkiewicz are you able to fix #32507?
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 is really borderline time. I don't know if the regression period is over or not in this case.
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.
Technically not over yet (6 days 7 hrs 😄)
I don't suggest to apply any penalty here since it was big PR.
But this minor issue can be fixed as follow-up.
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.
@aimane-chnaif sure will create a PR today
const report = getReport(reportID); | ||
if (!report || !isNotEmptyObject(report)) { |
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.
Any reason why we're using !isNotEmptyObject
instead of isEmptyObject
?
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.
Better type narrowing
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 think isEmptyObject
has the same type narrowing capabilities. @youssef-lr it may be a mistake, isEmptyObject
seems better
if (!report?.participantAccountIDs) { | ||
return false; | ||
} | ||
const sortedParticipanctsAccountIDs = report.parentReportActionIDs?.sort(); |
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 was overlooked.
const sortedParticipanctsAccountIDs = report.parentReportActionIDs?.sort(); | |
const sortedParticipanctsAccountIDs = report.participantAccountIDs.sort(); |
Before migration: _.sortBy(report.participantAccountIDs)
Details
Fixed Issues
$ #24927
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
web.mp4
Mobile Web - Chrome
Mobile Web - Safari
Desktop
desktop.mp4
iOS
ios.mp4
Android
android.mp4