migrate report setting write capability#85109
Conversation
|
@mananjadhav 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] |
| const goBack = useCallback(() => { | ||
| Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, route.params.backTo)); | ||
| }, [report.reportID, route.params.backTo]); | ||
| Navigation.goBack(backPath); |
There was a problem hiding this comment.
❌ CLEAN-REACT-PATTERNS-0 (docs)
React Compiler is enabled in this codebase (babel-plugin-react-compiler in babel.config.js). It automatically memoizes closures based on their captured variables, making manual useCallback wrappers redundant. The goBack and updateWriteCapability functions (lines 35 and 39) are both wrapped in useCallback, but the compiler will handle this memoization automatically.
Remove the useCallback wrappers and use plain functions instead:
const goBack = () => {
Navigation.goBack(backPath);
};
const updateWriteCapability = (newValue: ValueOf<typeof CONST.REPORT.WRITE_CAPABILITIES>) => {
updateWriteCapabilityUtil(report.reportID, newValue);
Navigation.goBack(backPath);
};Also remove useCallback from the import React, {useCallback} from 'react'; statement on line 1.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 986cf6e432
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| title={writeCapabilityText} | ||
| description={translate('writeCapabilityPage.label')} | ||
| onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.getRoute(reportID, backTo))} | ||
| onPress={() => Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.path))} |
There was a problem hiding this comment.
Pass reportID when opening dynamic write-capability route
This navigation call builds the dynamic URL with only DYNAMIC_ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.path, but getStateForDynamicRoute() only carries query params into route.params; it does not recover reportID from the base path. The target page is wrapped with withReportOrNotFound(), which reads route.params.reportID, so opening this screen from Report Settings can leave reportID undefined and send users to the NotFound/loading fallback instead of the write-capability selector.
Useful? React with 👍 / 👎.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Explanation of Change
Fixed Issues
$ #83368
PROPOSAL:
Tests
Same QA step
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