Repository navigation
[CP staging] Revert "Handle navigation properly when clicking on report link" #71376
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,6 @@ import {isEmailPublicDomain} from './LoginUtils'; | |
| import {getForReportAction, getMovedReportID} from './ModifiedExpenseMessage'; | ||
| import getStateFromPath from './Navigation/helpers/getStateFromPath'; | ||
| import {isFullScreenName} from './Navigation/helpers/isNavigatorName'; | ||
| import isSearchTopmostFullScreenRoute from './Navigation/helpers/isSearchTopmostFullScreenRoute'; | ||
| import {linkingConfig} from './Navigation/linkingConfig'; | ||
| import Navigation, {navigationRef} from './Navigation/Navigation'; | ||
| import type {MoneyRequestNavigatorParamList, ReportsSplitNavigatorParamList} from './Navigation/types'; | ||
|
|
@@ -6397,8 +6396,12 @@ function getDeletedTransactionMessage(action: ReportAction) { | |
|
|
||
| function getMovedTransactionMessage(report: OnyxEntry<Report>) { | ||
| const reportName = getReportName(report) ?? report?.reportName ?? ''; | ||
| const reportUrl = getReportURLForCurrentContext(report?.reportID); | ||
| return translateLocal('iou.movedTransaction', {reportUrl, reportName}); | ||
| const reportUrl = `${environmentURL}/r/${report?.reportID}`; | ||
| const message = translateLocal('iou.movedTransaction', { | ||
| reportUrl, | ||
| reportName, | ||
| }); | ||
| return message; | ||
| } | ||
|
|
||
| function getUnreportedTransactionMessage() { | ||
|
|
@@ -6423,8 +6426,8 @@ function getMovedActionMessage(action: ReportAction, report: OnyxEntry<Report>) | |
| const toPolicyName = getPolicyNameByID(toPolicyID); | ||
| return translateLocal('iou.movedAction', { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-4Objects passed as props should be properly memoized to prevent unnecessary re-renders. This object creation happens every time the function is called, which can impact performance. Consider extracting the object creation and memoizing it: const params = useMemo(() => ({
shouldHideMovedReportUrl: !isDM(report),
movedReportUrl: `${environmentURL}/r/${movedReportID}`,
newParentReportUrl: `${environmentURL}/r/${newParentReportID}`,
toPolicyName,
}), [report, movedReportID, newParentReportID, toPolicyName]);
return translateLocal('iou.movedAction', params); |
||
| shouldHideMovedReportUrl: !isDM(report), | ||
| movedReportUrl: getReportURLForCurrentContext(movedReportID), | ||
| newParentReportUrl: getReportURLForCurrentContext(newParentReportID), | ||
| movedReportUrl: `${environmentURL}/r/${movedReportID}`, | ||
| newParentReportUrl: `${environmentURL}/r/${newParentReportID}`, | ||
| toPolicyName, | ||
| }); | ||
| } | ||
|
|
@@ -6748,8 +6751,8 @@ function buildOptimisticMovedReportAction( | |
| const movedActionMessage = [ | ||
| { | ||
| html: shouldHideMovedReportUrl | ||
| ? `moved this <a href='${getReportURLForCurrentContext(movedReportID)}' target='_blank' rel='noreferrer noopener'>report</a> to the <a href='${getReportURLForCurrentContext(newParentReportID)}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace` | ||
| : `moved this report to the <a href='${getReportURLForCurrentContext(newParentReportID)}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`, | ||
| ? `moved this <a href='${CONST.NEW_EXPENSIFY_URL}r/${movedReportID}' target='_blank' rel='noreferrer noopener'>report</a> to the <a href='${CONST.NEW_EXPENSIFY_URL}r/${newParentReportID}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace` | ||
| : `moved this report to the <a href='${CONST.NEW_EXPENSIFY_URL}r/${newParentReportID}' target='_blank' rel='noreferrer noopener'>${policyName}</a> workspace`, | ||
| text: `moved this report to the ${policyName} workspace`, | ||
| type: CONST.REPORT.MESSAGE.TYPE.COMMENT, | ||
| }, | ||
|
|
@@ -6836,8 +6839,11 @@ function buildOptimisticTransactionAction( | |
| targetReportID: string, | ||
| ): ReportAction { | ||
| const reportName = allReports?.[targetReportID]?.reportName ?? ''; | ||
| const url = getReportURLForCurrentContext(targetReportID); | ||
| const [actionText, messageHtml] = [`moved this expense to ${reportName}`, `moved this expense to <a href='${url}' target='_blank' rel='noreferrer noopener'>${reportName}</a>`]; | ||
| const url = `${environmentURL}/r/${targetReportID}`; | ||
| const [actionText, messageHtml] = | ||
| type === CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION | ||
| ? [`moved this expense to ${reportName}`, `moved this expense to <a href='${url}' target='_blank' rel='noreferrer noopener'>${reportName}</a>`] | ||
| : ['moved this expense to your personal space', 'moved this expense to your personal space']; | ||
|
|
||
| return { | ||
| actionName: type, | ||
|
|
@@ -11791,15 +11797,6 @@ function getReportStatusTranslation(stateNum?: number, statusNum?: number): stri | |
| return ''; | ||
| } | ||
|
|
||
| function getReportURLForCurrentContext(reportID: string | undefined): string { | ||
| if (!reportID) { | ||
| return `${environmentURL}/r/`; | ||
| } | ||
| const isInSearchContext = isSearchTopmostFullScreenRoute(); | ||
| const relativePath = isInSearchContext ? ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID}) : ROUTES.REPORT_WITH_ID.getRoute(reportID); | ||
| return `${environmentURL}/${relativePath}`; | ||
| } | ||
|
|
||
| export { | ||
| areAllRequestsBeingSmartScanned, | ||
| buildOptimisticAddCommentReportAction, | ||
|
|
@@ -12190,7 +12187,6 @@ export { | |
| isWorkspaceThread, | ||
| isMoneyRequestReportEligibleForMerge, | ||
| getReportStatusTranslation, | ||
| getReportURLForCurrentContext, | ||
| getMovedActionMessage, | ||
| excludeParticipantsForDisplay, | ||
| getReportName, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
❌ PERF-4
Objects passed as props should be properly memoized to prevent unnecessary re-renders. Creating a new object on every function call can cause performance issues when this function is called frequently.
Consider memoizing the object or passing primitive values directly: