Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b3baa98
fix:Standardize Expense Report and Expense header with predictable bu…
thelullabyy Sep 3, 2026
c4e0403
merge main
thelullabyy Sep 6, 2026
d463be2
fix: issues
thelullabyy Sep 6, 2026
bc45a6d
fix: conflicts
thelullabyy Sep 15, 2026
8dade2f
Merge branch 'main' of https://github.com/Expensify/App into fix-04/9…
thelullabyy Sep 15, 2026
63a3b46
fix: Melvin feedback
thelullabyy Sep 15, 2026
2bd50ac
Merge branch 'main' of https://github.com/Expensify/App into fix-04/9…
thelullabyy Sep 17, 2026
198fbd2
fix: melvin comments
thelullabyy Sep 17, 2026
5030df4
Merge branch 'main' of https://github.com/Expensify/App into fix-04/9…
thelullabyy Sep 18, 2026
2718ed6
fix: improve the solution
thelullabyy Sep 18, 2026
439a185
fix: comment
thelullabyy Sep 18, 2026
f5a0329
fix: conflicts
thelullabyy Sep 26, 2026
ae3902f
fix: tests
thelullabyy Sep 26, 2026
84d845b
Merge branch 'main' of https://github.com/Expensify/App into fix-04/9…
thelullabyy Sep 26, 2026
ba8894a
fix: issues
thelullabyy Sep 26, 2026
ef5a4fa
Merge branch 'main' of https://github.com/Expensify/App into fix-04/9…
thelullabyy Sep 28, 2026
aa168a1
fix: conflicts
thelullabyy Oct 1, 2026
40f67c6
fix: simplify comments
thelullabyy Oct 1, 2026
251c937
fix: simplify comments
thelullabyy Oct 1, 2026
1ec4b7d
fix: issues
thelullabyy Oct 1, 2026
73df92b
fix: conflicts
thelullabyy Oct 1, 2026
b386fd0
Merge branch 'main' of https://github.com/Expensify/App into fix-04/9…
thelullabyy Oct 4, 2026
202325d
fix: resolve comments
thelullabyy Oct 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,10 @@ const ONYXKEYS = {
/** List of transaction IDs used when navigating to prev/next transaction when viewing it in RHP */
TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS: 'transactionThreadNavigationTransactionIDs',

/** Hash of the search snapshot that holds the transactions referenced by TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS.
* Used to fall back to snapshot data when the live transaction collection hasn't loaded those transactions yet (e.g. opening an expense from the Spend page as an approver). */
TRANSACTION_THREAD_NAVIGATION_SNAPSHOT_HASH: 'transactionThreadNavigationSnapshotHash',

/** Optional map of transactionID -> sibling descriptor for prev/next navigation in snapshot-backed flows (e.g. Home "Recently added"), where siblings may be absent from the main Onyx collections. When set, navigation resolves (and lazily creates) each sibling's thread on demand from its descriptor. */
TRANSACTION_THREAD_NAVIGATION_THREAD_REPORT_IDS: 'transactionThreadNavigationThreadReportIDs',

Expand Down Expand Up @@ -1910,6 +1914,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.REPORT_NAVIGATION_LAST_SEARCH_QUERY]: OnyxTypes.LastSearchParams;
[ONYXKEYS.NVP_LAST_ANDROID_LOGIN]: string;
[ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS]: string[];
[ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_SNAPSHOT_HASH]: number;
[ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_THREAD_REPORT_IDS]: Record<string, TransactionThreadNavigationDescriptor>;
[ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES]: OnyxTypes.ExportTemplate[];
[ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION]: OnboardingAccounting;
Expand Down
8 changes: 6 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2105,14 +2105,18 @@ const ROUTES = {
},
SEARCH_REPORT: {
route: 'search/view/:reportID/:reportActionID?',
getRoute: ({reportID, reportActionID, backTo}: {reportID: string | undefined; reportActionID?: string; backTo?: string}) => {
getRoute: ({reportID, reportActionID, backTo, anchorTransactionID}: {reportID: string | undefined; reportActionID?: string; backTo?: string; anchorTransactionID?: string}) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the SEARCH_REPORT route');
}

const baseRoute = reportActionID ? (`search/view/${reportID}/${reportActionID}` as const) : (`search/view/${reportID}` as const);
// Which expense in the prev/next carousel this screen is anchored to. The header falls back to it while
// the thread's own parent report action is still loading, so the carousel doesn't wink out of existence
// on a cold open (e.g. straight after clearing the cache).
const routeWithAnchor = anchorTransactionID ? (`${baseRoute}?anchorTransactionID=${anchorTransactionID}` as const) : baseRoute;

return getUrlWithBackToParam(baseRoute, backTo);
return getUrlWithBackToParam(routeWithAnchor, backTo);
},
},

Expand Down
87 changes: 76 additions & 11 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import useCarouselTransactionIDs from '@hooks/useCarouselTransactionIDs';
import useLocalize from '@hooks/useLocalize';
import useMobileSelectionMode from '@hooks/useMobileSelectionMode';
import useMoneyReportHeaderMoreContentVisibility from '@hooks/useMoneyReportHeaderMoreContentVisibility';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import useReportPrimaryAction from '@hooks/useReportPrimaryAction';
Expand All @@ -9,23 +11,30 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';

import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReportsSplitNavigatorParamList, RightModalNavigatorParamList} from '@libs/Navigation/types';
import {getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';

import type {OnyxEntry} from 'react-native-onyx';

import {useIsFocused, useRoute} from '@react-navigation/native';
import React, {useEffect} from 'react';
import React, {useCallback, useEffect} from 'react';
import {View} from 'react-native';

import HeaderLoadingBar from './HeaderLoadingBar';
import HeaderWithBackButton from './HeaderWithBackButton';
import MoneyReportHeaderActions from './MoneyReportHeaderActions';
import MoneyReportHeaderModals from './MoneyReportHeaderModals';
import MoneyReportHeaderMoreContent from './MoneyReportHeaderMoreContent';
import MoneyRequestReportNavigation from './MoneyRequestReportView/MoneyRequestReportNavigation';
import MoneyRequestReportTransactionsNavigation from './MoneyRequestReportView/MoneyRequestReportTransactionsNavigation';
import {PaymentAnimationsProvider} from './PaymentAnimationsContext';
import {useSearchSelectionActions} from './Search/SearchContext';

Expand Down Expand Up @@ -75,15 +84,49 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt

const transactions = Object.values(reportTransactions);

// The same filtered list MoneyRequestReportTransactionsNavigation renders from, so the two agree on whether
// there is an expense carousel to show. Gating on the raw Onyx list let this pick the expense branch while the
// carousel found nothing to page through, leaving the user with neither set of arrows.
const {transactionIDs: activeTransactionIDs} = useCarouselTransactionIDs();

const singleTransactionID = transactions.length === 1 ? transactions.at(0)?.transactionID : undefined;

const threadParentReportActionID = moneyRequestReport?.parentReportActionID;
const threadTransactionIDSelector = useCallback(
(parentReportActions: OnyxEntry<OnyxTypes.ReportActions>) => {
const parentReportAction = threadParentReportActionID ? parentReportActions?.[threadParentReportActionID] : undefined;
return isMoneyRequestAction(parentReportAction) ? getOriginalMessage(parentReportAction)?.IOUTransactionID : undefined;
},
[threadParentReportActionID],
);
const [threadTransactionID] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(moneyRequestReport?.parentReportID)}`, {selector: threadTransactionIDSelector});

const anchorTransactionIDFromRoute = route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT ? route.params.anchorTransactionID : undefined;
const routeAnchorTransactionID = anchorTransactionIDFromRoute && activeTransactionIDs.includes(anchorTransactionIDFromRoute) ? anchorTransactionIDFromRoute : undefined;
const carouselAnchorTransactionID = route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT ? undefined : (singleTransactionID ?? threadTransactionID ?? routeAnchorTransactionID);
const shouldShowTransactionNavigation =
route.name !== SCREENS.REPORT && !!carouselAnchorTransactionID && activeTransactionIDs.length > 1 && activeTransactionIDs.includes(carouselAnchorTransactionID);
Comment thread
thelullabyy marked this conversation as resolved.
Resolved

const styles = useThemeStyles();

const {isWideRHPDisplayedOnWideLayout, isSuperWideRHPDisplayedOnWideLayout, shouldUseNarrowLayout: shouldUseNarrowLayoutOnWideRHP} = useResponsiveLayoutOnWideRHP();

const shouldShowHeaderButtonsInHeaderRow = isInLandscapeMode || !shouldDisplayNarrowVersion || isWideRHPDisplayedOnWideLayout || isSuperWideRHPDisplayedOnWideLayout;

const isReportInRHP = route.name !== SCREENS.REPORT;
const shouldDisplaySearchRouter = !isReportInRHP || isSmallScreenWidth;
const isReportInSearch = route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT || route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT;

// The report-level arrows page through search results, so they are search-only; the expense carousel takes
// precedence wherever this report is anchored to one.
const shouldShowReportNavigation = !shouldShowTransactionNavigation && isReportInSearch;

const {statusBarType, shouldShowNextStep, hasStatusOrNextStep} = useMoneyReportHeaderMoreContentVisibility(reportIDProp);
const shouldRenderActionsInHeaderRow = shouldShowHeaderButtonsInHeaderRow && !hasStatusOrNextStep;
Comment thread
thelullabyy marked this conversation as resolved.
Resolved
// A narrow header has room for one control beside the title, and prev/next wins it: the arrows are the only way
// to reach this expense's siblings, whereas the search router is still one back-press away on the screen the
// user came from. Where no arrows are rendered the magnifier keeps its place, as it did before.
const shouldDisplaySearchRouter = !isReportInRHP || (isSmallScreenWidth && !shouldShowTransactionNavigation && !shouldShowReportNavigation);

const backTo = (route.params as {backTo?: Route} | undefined)?.backTo;

const primaryAction = useReportPrimaryAction(reportIDProp);
Expand Down Expand Up @@ -138,14 +181,29 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt
shouldEnableDetailPageNavigation
openParentReportInCurrentTab
>
{shouldShowHeaderButtonsInHeaderRow && (
<MoneyReportHeaderActions
reportID={reportIDProp}
primaryAction={primaryAction}
isReportInSearch={isReportInSearch}
backTo={backTo}
/>
)}
<View style={[styles.flexRow, styles.alignItemsCenter, styles.gap3]}>
{shouldRenderActionsInHeaderRow && (
<MoneyReportHeaderActions
reportID={reportIDProp}
primaryAction={primaryAction}
isReportInSearch={isReportInSearch}
backTo={backTo}
/>
)}
{shouldShowTransactionNavigation && !!carouselAnchorTransactionID ? (
<MoneyRequestReportTransactionsNavigation
currentTransactionID={carouselAnchorTransactionID}
shouldDisplayNarrowVersion={!shouldShowHeaderButtonsInHeaderRow}
/>
) : (
shouldShowReportNavigation && (
<MoneyRequestReportNavigation
reportID={reportIDProp}
shouldDisplayNarrowVersion={!shouldShowHeaderButtonsInHeaderRow}
/>
)
)}
</View>
</HeaderWithBackButton>
{!shouldShowHeaderButtonsInHeaderRow && (
<MoneyReportHeaderActions
Expand All @@ -155,7 +213,14 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt
backTo={backTo}
/>
)}
<MoneyReportHeaderMoreContent reportID={reportIDProp} />
<MoneyReportHeaderMoreContent
reportID={reportIDProp}
primaryAction={primaryAction}
backTo={backTo}
statusBarType={statusBarType}
shouldShowNextStep={shouldShowNextStep}
shouldRenderActionsInRow={shouldShowHeaderButtonsInHeaderRow && !shouldRenderActionsInHeaderRow}
/>
<HeaderLoadingBar />
</View>
);
Expand Down
68 changes: 44 additions & 24 deletions src/components/MoneyReportHeaderMoreContent.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import useMoneyReportHeaderStatusBar from '@hooks/useMoneyReportHeaderStatusBar';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useResponsiveLayoutOnWideRHP from '@hooks/useResponsiveLayoutOnWideRHP';
import useThemeStyles from '@hooks/useThemeStyles';

import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReportsSplitNavigatorParamList, RightModalNavigatorParamList} from '@libs/Navigation/types';
import {isGroupPolicy} from '@libs/PolicyUtils';
import {isInvoiceReport as isInvoiceReportUtil} from '@libs/ReportUtils';

import type CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';

Expand All @@ -22,20 +17,37 @@ import {useRoute} from '@react-navigation/native';
import React from 'react';
import {View} from 'react-native';

import type {MoneyReportHeaderActionsProps} from './MoneyReportHeaderActions/types';

import MoneyReportHeaderActions from './MoneyReportHeaderActions';
import MoneyReportHeaderNextStep from './MoneyReportHeaderNextStep';
import MoneyReportHeaderStatusBarSection from './MoneyReportHeaderStatusBarSection';
import {useMoneyReportTransactionThread} from './MoneyReportTransactionThreadContext';
import MoneyRequestReportNavigation from './MoneyRequestReportView/MoneyRequestReportNavigation';

type MoneyReportHeaderMoreContentProps = {
reportID: string | undefined;

/** The report's primary action, forwarded to the actions row */
primaryAction: MoneyReportHeaderActionsProps['primaryAction'];

/** Route to navigate back to */
backTo: Route | undefined;

/** Which status bar to render, resolved by the header via useMoneyReportHeaderMoreContentVisibility */
statusBarType: ValueOf<typeof CONST.REPORT.STATUS_BAR_TYPE> | undefined;

/** Whether the next step bar should be rendered, resolved alongside `statusBarType` */
shouldShowNextStep: boolean;

/** Whether the report actions belong at the end of this row. The header renders them itself when this row is empty. */
shouldRenderActionsInRow: boolean;
};

/**
* Cheap visibility gate — fetches minimal data to decide whether the more-content section
* should render at all, avoiding expensive hooks in the body when nothing is shown.
* Cheap visibility gate that decides whether the more-content section should render at all,
* avoiding expensive hooks in the body when nothing is shown.
*/
function MoneyReportHeaderMoreContent({reportID}: MoneyReportHeaderMoreContentProps) {
function MoneyReportHeaderMoreContent({reportID, primaryAction, backTo, statusBarType, shouldShowNextStep, shouldRenderActionsInRow}: MoneyReportHeaderMoreContentProps) {
const route = useRoute<
| PlatformStackRouteProp<ReportsSplitNavigatorParamList, typeof SCREENS.REPORT>
| PlatformStackRouteProp<RightModalNavigatorParamList, typeof SCREENS.RIGHT_MODAL.EXPENSE_REPORT>
Expand All @@ -45,13 +57,9 @@ function MoneyReportHeaderMoreContent({reportID}: MoneyReportHeaderMoreContentPr
const isReportInSearch = route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT || route.name === SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT;

const [moneyRequestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(moneyRequestReport?.policyID)}`);
const {shouldShowStatusBar, statusBarType} = useMoneyReportHeaderStatusBar(reportID, moneyRequestReport?.chatReportID);

const isInvoiceReport = isInvoiceReportUtil(moneyRequestReport);
const shouldShowNextStep = isGroupPolicy(policy) && !isInvoiceReport && !shouldShowStatusBar;

const shouldShowMoreContent = shouldShowNextStep || !!statusBarType || isReportInSearch;
const hasStatusOrNextStep = shouldShowNextStep || !!statusBarType;
const shouldShowMoreContent = hasStatusOrNextStep || shouldRenderActionsInRow;

if (!shouldShowMoreContent) {
return null;
Expand All @@ -63,6 +71,9 @@ function MoneyReportHeaderMoreContent({reportID}: MoneyReportHeaderMoreContentPr
statusBarType={statusBarType}
isReportInSearch={isReportInSearch}
shouldShowNextStep={shouldShowNextStep}
primaryAction={primaryAction}
backTo={backTo}
shouldRenderActionsInRow={shouldRenderActionsInRow}
/>
);
}
Expand All @@ -72,14 +83,21 @@ type MoneyReportHeaderMoreContentBodyProps = {
statusBarType: ValueOf<typeof CONST.REPORT.STATUS_BAR_TYPE> | undefined;
isReportInSearch: boolean;
shouldShowNextStep: boolean;
primaryAction: MoneyReportHeaderActionsProps['primaryAction'];
backTo: Route | undefined;
shouldRenderActionsInRow: boolean;
};

function MoneyReportHeaderMoreContentBody({moneyRequestReport, statusBarType, isReportInSearch, shouldShowNextStep}: MoneyReportHeaderMoreContentBodyProps) {
function MoneyReportHeaderMoreContentBody({
moneyRequestReport,
statusBarType,
isReportInSearch,
shouldShowNextStep,
primaryAction,
backTo,
shouldRenderActionsInRow,
}: MoneyReportHeaderMoreContentBodyProps) {
const styles = useThemeStyles();
const {shouldUseNarrowLayout, isMediumScreenWidth} = useResponsiveLayout();
const shouldDisplayNarrowVersion = shouldUseNarrowLayout || isMediumScreenWidth;
const {isWideRHPDisplayedOnWideLayout, isSuperWideRHPDisplayedOnWideLayout} = useResponsiveLayoutOnWideRHP();
const shouldDisplayNarrowMoreButton = !shouldDisplayNarrowVersion || isWideRHPDisplayedOnWideLayout || isSuperWideRHPDisplayedOnWideLayout;

const reportID = moneyRequestReport?.reportID;
const {iouTransactionID} = useMoneyReportTransactionThread();
Expand All @@ -94,10 +112,12 @@ function MoneyReportHeaderMoreContentBody({moneyRequestReport, statusBarType, is
iouTransactionID={iouTransactionID}
/>
</View>
{isReportInSearch && (
<MoneyRequestReportNavigation
{shouldRenderActionsInRow && (
<MoneyReportHeaderActions
reportID={reportID}
shouldDisplayNarrowVersion={!shouldDisplayNarrowMoreButton}
primaryAction={primaryAction}
isReportInSearch={isReportInSearch}
backTo={backTo}
/>
)}
</View>
Expand Down
Loading
Loading