Skip to content
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

Hide the search router button when the report of a search result is opened in RHP #50964

8 changes: 6 additions & 2 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import isReportOpenInRHP from '@libs/Navigation/isReportOpenInRHP';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
Expand Down Expand Up @@ -157,6 +158,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const {isDelegateAccessRestricted, delegatorEmail} = useDelegateUserDetails();
const [isNoDelegateAccessMenuVisible, setIsNoDelegateAccessMenuVisible] = useState(false);

const isReportInRHP = isReportOpenInRHP(navigationRef?.getRootState());
const shouldDisplaySearchRouter = !isReportInRHP;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #51730 where we had the issue that whilst RHP is closing, the last route won't be report RHP anymore, so isReportInRHP becomes false and the search icon is briefly shown (as the RHP is closing).


const confirmPayment = useCallback(
(type?: PaymentMethodType | undefined, payAsBusiness?: boolean) => {
if (!type || !chatReport) {
Expand Down Expand Up @@ -309,7 +313,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
report={moneyRequestReport}
policy={policy}
shouldShowBackButton={shouldUseNarrowLayout}
shouldDisplaySearchRouter
shouldDisplaySearchRouter={shouldDisplaySearchRouter}
onBackButtonPress={onBackButtonPress}
// Shows border if no buttons or banners are showing below the header
shouldShowBorderBottom={!isMoreContentShown}
Expand Down
8 changes: 6 additions & 2 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import isReportOpenInRHP from '@libs/Navigation/isReportOpenInRHP';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
Expand Down Expand Up @@ -62,6 +63,9 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
const isDuplicate = TransactionUtils.isDuplicate(transaction?.transactionID ?? '');
const reportID = report?.reportID;

const isReportInRHP = isReportOpenInRHP(navigationRef?.getRootState());
const shouldDisplaySearchRouter = !isReportInRHP;

const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID ?? '-1']);

const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID ?? '-1', parentReport, policy);
Expand Down Expand Up @@ -154,7 +158,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
}}
policy={policy}
shouldShowBackButton={shouldUseNarrowLayout}
shouldDisplaySearchRouter
shouldDisplaySearchRouter={shouldDisplaySearchRouter}
onBackButtonPress={onBackButtonPress}
>
{shouldShowMarkAsCashButton && !shouldUseNarrowLayout && (
Expand Down
8 changes: 6 additions & 2 deletions src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import isReportOpenInRHP from '@libs/Navigation/isReportOpenInRHP';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as ReportUtils from '@libs/ReportUtils';
import FreeTrialBadge from '@pages/settings/Subscription/FreeTrialBadge';
Expand Down Expand Up @@ -140,6 +141,9 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
const shouldUseGroupTitle = isGroupChat && (!!report?.reportName || !isMultipleParticipant);
const isLoading = !report?.reportID || !title;

const isReportInRHP = isReportOpenInRHP(navigationRef?.getRootState());
const shouldDisplaySearchRouter = !isReportInRHP;

return (
<View
style={[shouldShowBorderBottom && styles.borderBottom]}
Expand Down Expand Up @@ -280,7 +284,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
{isTaskReport && !shouldUseNarrowLayout && ReportUtils.isOpenTaskReport(report, parentReportAction) && <TaskHeaderActionButton report={report} />}
{canJoin && !shouldUseNarrowLayout && joinButton}
</View>
<SearchButton style={styles.ml4} />
{shouldDisplaySearchRouter && <SearchButton style={styles.ml4} />}
</View>
<ConfirmModal
isVisible={isDeleteTaskConfirmModalVisible}
Expand Down
Loading