-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[NoQA] Remove call to getReportNameValuePairs() in method canUserPerformWriteAction from ReportUtils.ts part 6 #72585
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
Conversation
|
@DylanDylann 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] |
src/libs/ReportUtils.ts
Outdated
| }; | ||
| const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${targetChatReportID}`]; | ||
| const canUserPerformWriteActionVariable = canUserPerformWriteAction(report); | ||
| const canUserPerformWriteActionVariable = canUserPerformWriteAction(report, false); |
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.
Why do we pass false value 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.
@DylanDylann It's called in prepareOnboardingOnyxData, i think can't be archived in this case
| failureData: deleteExpenseFailureData, | ||
| successData: deleteExpenseSuccessData, | ||
| } = getDeleteTrackExpenseInformation(splitTransaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), undeletedTransaction?.transactionID, currentReportAction); | ||
| } = getDeleteTrackExpenseInformation(splitTransaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), undeletedTransaction?.transactionID, currentReportAction, 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.
Why do we pass 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.
Relating to this matter, I am asking here: #72086 (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.
I think we can move forward because the rest looks fine
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 really not a fan of passing undefined. Why is that any different (or better) than just not passing anything at all 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.
@tgolen If we make this parameter optional, contributors might forget to include it even though it’s required (assuming it’s still handled internally as before) which could easily lead to regressions. We’ve already seen similar cases in the past, so I think it’s better to mark it as required. Moreover, in most usages we actually need to pass this value (there are only one or two exceptions)
In this place, it’s a new feature and the author forgot to pass the new parameter. I’ve asked them to simplify the logic here. For this PR, I think it’s fine to temporarily set it as 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.
OK, so the idea is that if it's required, even to pass undefined, it at least alerts other engineers that they need to make a real decision about passing this parameter or not? They can't just use this method without deciding one way or the other?
I guess that makes sense. It would be nice if there was a better way of doing that, but I am OK with this for now.
Thanks!
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
| const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); | ||
| const cleanSearchTerm = useMemo(() => searchTerm.trim().toLowerCase(), [searchTerm]); | ||
| const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); | ||
| const [archivedReportsIdSet = new Set<string>()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { |
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.
Since this pattern is being used in multiple places, it seems like a good candidate for it's own custom hook. There are some instances using archivedReportsIdSetSelector and some that have essentially copies of the selector below.
I searched the code for const [archivedReportsIdSet = new Set<string>()] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { but there might be others
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 agree
cc @thelullabyy
| failureData: deleteExpenseFailureData, | ||
| successData: deleteExpenseSuccessData, | ||
| } = getDeleteTrackExpenseInformation(splitTransaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), undeletedTransaction?.transactionID, currentReportAction); | ||
| } = getDeleteTrackExpenseInformation(splitTransaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID), undeletedTransaction?.transactionID, currentReportAction, 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.
I am really not a fan of passing undefined. Why is that any different (or better) than just not passing anything at all in this case?
|
@DylanDylann @tgolen Part 5 is reverted and i recreated PR here. I will continue on this once it's merged |
|
@DylanDylann Updated. Please help to check |
|
@thelullabyy Thanks for update, your update looks fine. Let's me review all again |
DylanDylann
left a 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.
Nice 💚
|
@tgolen I’m really looking forward to getting this PR merged — it’s the final one in the [Remove call to getReportNameValuePairs() tasks] 😄 |
tgolen
left a 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.
Wowie!!! Let's do it!
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
Hi @thelullabyy No QA for this? |
|
🚀 Deployed to staging by https://github.com/tgolen in version: 9.2.35-0 🚀
|
|
@izarutskaya Yes, the main work in this PR is code cleanup and refactoring |
|
Reverted this here: #73095 |
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.2.35-4 🚀
|
…
Explanation of Change
Fixed Issues
$#67103
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop