-
Notifications
You must be signed in to change notification settings - Fork 4k
[Better Expense Report View] Improve the link interactivity in the sub-header line of report card inside Reports, RHP & Report view #63441
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
mountiny
merged 3 commits into
Expensify:main
from
software-mansion-labs:korytko/fix-link-in-header
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| import {useRoute} from '@react-navigation/native'; | ||
| import React from 'react'; | ||
| import type {StyleProp, ViewStyle} from 'react-native'; | ||
| import type {StyleProp, TextStyle} from 'react-native'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import useHover from '@hooks/useHover'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useRootNavigationState from '@hooks/useRootNavigationState'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
|
|
@@ -16,8 +19,8 @@ import NAVIGATORS from '@src/NAVIGATORS'; | |
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import SCREENS from '@src/SCREENS'; | ||
| import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback'; | ||
| import Text from './Text'; | ||
| import TextLink from './TextLink'; | ||
|
|
||
| type ParentNavigationSubtitleProps = { | ||
| parentNavigationSubtitleData: ParentNavigationSummaryParams; | ||
|
|
@@ -29,7 +32,7 @@ type ParentNavigationSubtitleProps = { | |
| parentReportActionID?: string; | ||
|
|
||
| /** PressableWithoutFeedback additional styles */ | ||
| pressableStyles?: StyleProp<ViewStyle>; | ||
| pressableStyles?: StyleProp<TextStyle>; | ||
|
|
||
| /** Whether to open the parent report link in the current tab if possible */ | ||
| openParentReportInCurrentTab?: boolean; | ||
|
|
@@ -44,6 +47,13 @@ function ParentNavigationSubtitle({ | |
| }: ParentNavigationSubtitleProps) { | ||
| const currentRoute = useRoute(); | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const { | ||
| hovered, | ||
| bind: {onMouseEnter, onMouseLeave}, | ||
| } = useHover(); | ||
|
|
||
| const {workspaceName, reportName} = parentNavigationSubtitleData; | ||
| const {translate} = useLocalize(); | ||
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`, {canBeMissing: false}); | ||
|
|
@@ -56,61 +66,64 @@ function ParentNavigationSubtitle({ | |
| return; | ||
| } | ||
|
|
||
| return ( | ||
| <PressableWithoutFeedback | ||
| onPress={() => { | ||
| const parentAction = getReportAction(parentReportID, parentReportActionID); | ||
| const isVisibleAction = shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? CONST.DEFAULT_NUMBER_ID, canUserPerformWriteAction); | ||
|
|
||
| if (openParentReportInCurrentTab && isReportInRHP) { | ||
| // If the report is displayed in RHP in Reports tab, we want to stay in the current tab after opening the parent report | ||
| if (currentFullScreenRoute?.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR) { | ||
| const lastRoute = currentFullScreenRoute?.state?.routes.at(-1); | ||
| if (lastRoute?.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT) { | ||
| const moneyRequestReportID = (lastRoute?.params as SearchFullscreenNavigatorParamList[typeof SCREENS.SEARCH.MONEY_REQUEST_REPORT])?.reportID; | ||
| // If the parent report is already displayed underneath RHP, simply dismiss the modal | ||
| if (moneyRequestReportID === parentReportID) { | ||
| Navigation.dismissModal(); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: parentReportID})); | ||
| return; | ||
| } | ||
| const onPress = () => { | ||
| const parentAction = getReportAction(parentReportID, parentReportActionID); | ||
| const isVisibleAction = shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? CONST.DEFAULT_NUMBER_ID, canUserPerformWriteAction); | ||
|
|
||
| if (openParentReportInCurrentTab && isReportInRHP) { | ||
| // If the report is displayed in RHP in Reports tab, we want to stay in the current tab after opening the parent report | ||
| if (currentFullScreenRoute?.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR) { | ||
| const lastRoute = currentFullScreenRoute?.state?.routes.at(-1); | ||
| if (lastRoute?.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT) { | ||
| const moneyRequestReportID = (lastRoute?.params as SearchFullscreenNavigatorParamList[typeof SCREENS.SEARCH.MONEY_REQUEST_REPORT])?.reportID; | ||
| // If the parent report is already displayed underneath RHP, simply dismiss the modal | ||
| if (Navigation.getTopmostReportId() === parentReportID) { | ||
| if (moneyRequestReportID === parentReportID) { | ||
| Navigation.dismissModal(); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| if (isVisibleAction) { | ||
| Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, parentReportActionID)); | ||
| } else { | ||
| Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID)); | ||
| } | ||
| }} | ||
| accessibilityLabel={translate('threads.parentNavigationSummary', {reportName, workspaceName})} | ||
| role={CONST.ROLE.LINK} | ||
| style={pressableStyles} | ||
| Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: parentReportID})); | ||
| return; | ||
| } | ||
|
|
||
| // If the parent report is already displayed underneath RHP, simply dismiss the modal | ||
| if (Navigation.getTopmostReportId() === parentReportID) { | ||
| Navigation.dismissModal(); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| if (isVisibleAction) { | ||
| Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID, parentReportActionID)); | ||
| } else { | ||
| Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(parentReportID)); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <Text | ||
| style={[styles.optionAlternateText, styles.textLabelSupporting]} | ||
| numberOfLines={1} | ||
| > | ||
| <Text | ||
| style={[styles.optionAlternateText, styles.textLabelSupporting]} | ||
| numberOfLines={1} | ||
| > | ||
| {!!reportName && ( | ||
| <> | ||
| <Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{`${translate('threads.from')} `}</Text> | ||
| <Text style={[styles.optionAlternateText, styles.textLabelSupporting, styles.link]}>{reportName}</Text> | ||
| </> | ||
| )} | ||
| {!!workspaceName && workspaceName !== reportName && ( | ||
| <Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{` ${translate('threads.in')} ${workspaceName}`}</Text> | ||
| )} | ||
| </Text> | ||
| </PressableWithoutFeedback> | ||
| {!!reportName && ( | ||
| <> | ||
| <Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{`${translate('threads.from')} `}</Text> | ||
| <TextLink | ||
| onMouseEnter={onMouseEnter} | ||
| onMouseLeave={onMouseLeave} | ||
| onPress={onPress} | ||
| accessibilityLabel={translate('threads.parentNavigationSummary', {reportName, workspaceName})} | ||
| style={[pressableStyles, styles.optionAlternateText, styles.textLabelSupporting, hovered ? StyleUtils.getColorStyle(theme.linkHover) : styles.link]} | ||
| > | ||
|
Comment on lines
+112
to
+118
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. This changed caused We should set prop |
||
| {reportName} | ||
| </TextLink> | ||
| </> | ||
| )} | ||
| {!!workspaceName && workspaceName !== reportName && ( | ||
| <Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{` ${translate('threads.in')} ${workspaceName}`}</Text> | ||
| )} | ||
| </Text> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
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.
We should have considered the case when report screen remains in the navigation stack, but it isn't displayed underneath RHP.
More details: #76325 (comment)