Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2750b50
Push data hooks into the body, thin out ReportActionsView
LukasMod Jun 16, 2026
950d4ce
Introduce ReportActions orchestrator; route ReportScreen through it
LukasMod Jun 16, 2026
73e8c3a
Rewire MoneyRequestReportView to the body
LukasMod Jun 16, 2026
9b61f3c
Delete ReportActionsView
LukasMod Jun 16, 2026
4075453
Add MoneyRequestReportView unit test
LukasMod Jun 16, 2026
0929b0a
Update stale ReportActionsView doc comments to ReportActionsList
LukasMod Jun 16, 2026
09a9340
update ReportActionsList perf test
LukasMod Jun 16, 2026
faa7faa
clean up comments
LukasMod Jun 16, 2026
5ec39cb
add no-unsafe-type-assertion for mocks
LukasMod Jun 17, 2026
abbe2fc
Merge branch 'main' of github.com:Expensify/App into decompose/ral-6
LukasMod Jun 22, 2026
33f4970
Add ReportActionsSkeletonGuard with useReportActionsDataContext
LukasMod Jun 22, 2026
0c8a4c1
split context to guardData and contentData
LukasMod Jun 23, 2026
db5f1e6
clean up comments
LukasMod Jun 23, 2026
73582a3
fix knip
LukasMod Jun 23, 2026
3ab6856
Split into custom hooks
LukasMod Jun 25, 2026
5f2f310
Rename, split context
LukasMod Jun 25, 2026
79acea1
Merge branch 'main' of github.com:Expensify/App into decompose/ral-6
LukasMod Jun 25, 2026
f3ed365
resolve conflicts
LukasMod Jun 25, 2026
1b2af34
add useMarkOpenReportEndOnSkeleton
LukasMod Jun 25, 2026
c95f999
fix loading edge case window
LukasMod Jun 25, 2026
2c4a6ea
Make visibleReportActionsData stable
LukasMod Jun 25, 2026
ce3e927
remove latch
LukasMod Jun 25, 2026
f97d91f
move isConciergeMainDM logic up
LukasMod Jun 25, 2026
36f14bf
remove old ref to ReportActionsView
LukasMod Jun 25, 2026
9eebbb1
Merge remote-tracking branch 'upstream/main' into decompose/ral-6
LukasMod Jun 26, 2026
c2e877a
Merge branch 'main' of github.com:Expensify/App into decompose/ral-6
LukasMod Jun 29, 2026
4e9467f
Merge branch 'main' of github.com:Expensify/App into decompose/ral-6
LukasMod Jun 29, 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
2 changes: 1 addition & 1 deletion contributingGuides/OBSERVABILITY_METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This document lists all implemented telemetry metrics in the Expensify App.
- Technical: Report actions list rendered (onLayout event)
- Report data loaded from Onyx (reportID, type, chatType)
- Report actions list layout complete (we are waiting for the first page data render, so if there is any data in the Onyx, we'll not wait for the API)
- Called in [`src/pages/home/report/ReportActionsView.tsx`](https://github.com/Expensify/App/blob/8f123f449f1a4533830b18a1040c9a5f1949821d/src/pages/home/report/ReportActionsView.tsx#L272) and [`src/components/MoneyRequestReportActionsList.tsx`](https://github.com/Expensify/App/blob/8f123f449f1a4533830b18a1040c9a5f1949821d/src/components/MoneyRequestReportActionsList.tsx#L649)
- Called in the list body `src/pages/inbox/report/ReportActionsList.tsx`
**Span ID**: `${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportID}`
**Attributes**: `is_transaction_thread`, `is_one_transaction_report`, `report_type`, `chat_type`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useIsReportActionsLoaded from '@hooks/useIsReportActionsLoaded';
import useLoadReportActions from '@hooks/useLoadReportActions';
import useLocalize from '@hooks/useLocalize';
import useMarkOpenReportEndOnSkeleton from '@hooks/useMarkOpenReportEndOnSkeleton';
import useNetworkWithOfflineStatus from '@hooks/useNetworkWithOfflineStatus';
import useNewTransactions from '@hooks/useNewTransactions';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -191,12 +192,7 @@ function MoneyRequestReportActionsList({onLayout}: MoneyRequestReportListProps)
isOffline,
showReportActionsLoadingState: !!showReportActionsLoadingState,
};
useEffect(() => {
if (!shouldShowOpenReportLoadingSkeleton || !report) {
return;
}
markOpenReportEnd(report, {warm: false});
}, [report, shouldShowOpenReportLoadingSkeleton]);
useMarkOpenReportEndOnSkeleton(report, shouldShowOpenReportLoadingSkeleton);

const lastAction = visibleReportActions.at(-1);

Expand Down
25 changes: 12 additions & 13 deletions src/components/MoneyRequestReportView/MoneyRequestReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import MoneyRequestReceiptView from '@components/ReportActionItem/MoneyRequestReceiptView';
import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView';
import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView';
import useMarkOpenReportEndOnSkeleton from '@hooks/useMarkOpenReportEndOnSkeleton';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import usePaginatedReportActions from '@hooks/usePaginatedReportActions';
Expand All @@ -28,11 +29,11 @@ import {getFilteredReportActionsForReportView, getOneTransactionThreadReportID}
import {getReportOfflinePendingActionAndErrors, isReportTransactionThread} from '@libs/ReportUtils';
import {buildCannedSearchQuery} from '@libs/SearchQueryUtils';
import {cancelSpan} from '@libs/telemetry/activeSpans';
import markOpenReportEnd from '@libs/telemetry/markOpenReportEnd';
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
import Navigation from '@navigation/Navigation';
import ReportActionsView from '@pages/inbox/report/ReportActionsView';
import ReportActionsList from '@pages/inbox/report/ReportActionsList';
import ReportFooter from '@pages/inbox/report/ReportFooter';
import UserTypingEventListener from '@pages/inbox/report/UserTypingEventListener';
import CONST from '@src/CONST';
import NAVIGATORS from '@src/NAVIGATORS';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -149,7 +150,7 @@ function MoneyRequestReportView({report, reportLoadingState, shouldDisplayReport
}, [reportID]);

// Special case handling a report that is a transaction thread
// If true we will use standard `ReportActionsView` to display report data and a special header, anything else is handled via `MoneyRequestReportActionsList`
// If true we will use the standard `ReportActionsList` to display report data and a special header, anything else is handled via `MoneyRequestReportActionsList`
const isTransactionThreadView = isReportTransactionThread(report);

// Prevent the empty state flash by ensuring transaction data is fully loaded before deciding which view to render
Expand Down Expand Up @@ -200,12 +201,7 @@ function MoneyRequestReportView({report, reportLoadingState, shouldDisplayReport
};
}, [reportID]);

useEffect(() => {
if (!shouldShowOpenReportLoadingSkeleton || !report) {
return;
}
markOpenReportEnd(report, {warm: false});
}, [report, shouldShowOpenReportLoadingSkeleton]);
useMarkOpenReportEndOnSkeleton(report, shouldShowOpenReportLoadingSkeleton);

if (shouldShowOpenReportLoadingSkeleton) {
const skeletonReasonAttributes: SkeletonSpanReasonAttributes = {
Expand Down Expand Up @@ -275,10 +271,13 @@ function MoneyRequestReportView({report, reportLoadingState, shouldDisplayReport
{shouldDisplayMoneyRequestActionsList ? (
<MoneyRequestReportActionsList onLayout={onLayout} />
) : (
<ReportActionsView
reportID={reportID}
onLayout={onLayout}
/>
<>
<ReportActionsList
reportID={report.reportID}
onLayout={onLayout}
/>
<UserTypingEventListener report={report} />
</>
)}
{shouldDisplayReportFooter ? (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useIsReportReadyToDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function useIsReportReadyToDisplay(report: OnyxEntry<Report>, reportIDFromRoute:
* When false the report is not ready to be fully displayed
*/
const isCurrentReportLoadedFromOnyx = useMemo((): boolean => {
// This is necessary so that when we are retrieving the next report data from Onyx the ReportActionsView will remount completely
// This is necessary so that when we are retrieving the next report data from Onyx the ReportActionsList will remount completely
const isTransitioning = report && report?.reportID?.toString() !== reportIDFromRoute;
return reportIDFromRoute !== '' && !!report?.reportID && !isTransitioning;
}, [report, reportIDFromRoute]);
Expand Down
30 changes: 30 additions & 0 deletions src/hooks/useLinkedMessageOfflineLoading.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {useEffect} from 'react';
import {updateLoadingInitialReportAction} from '@libs/actions/Report';
import useNetwork from './useNetwork';

type UseLinkedMessageOfflineLoadingParams = {
/** The ID of the report whose initial-actions loading flag should be cleared */
reportID: string;

/** The report action ID linked from the route, if any */
reportActionIDFromRoute: string | undefined;
};

/**
* When deep-linking to a message while offline, the linked actions are already cached, so clear the
* initial-actions loading flag instead of waiting for OpenReport. In the content, not the guard, because it
* only runs offline, where no skeleton shows.
*/
function useLinkedMessageOfflineLoading({reportID, reportActionIDFromRoute}: UseLinkedMessageOfflineLoadingParams) {
const {isOffline} = useNetwork();

useEffect(() => {
// When we linked to message - we do not need to wait for initial actions - they already exists
if (!reportActionIDFromRoute || !isOffline) {
return;
}
updateLoadingInitialReportAction(reportID);
}, [isOffline, reportID, reportActionIDFromRoute]);
}

export default useLinkedMessageOfflineLoading;
21 changes: 21 additions & 0 deletions src/hooks/useMarkOpenReportEndOnSkeleton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {useEffect} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import markOpenReportEnd from '@libs/telemetry/markOpenReportEnd';
import type * as OnyxTypes from '@src/types/onyx';

/**
* Closes the open-report performance span as a cold open (`warm: false`) the moment a cold-load skeleton
* appears. Shared by every report surface that gates its own skeleton (the chat-list guard, the route
* orchestrator, and the money-request views): the open-report span must still close even though the list
* body — which would otherwise own this mark once mounted — isn't mounted while the skeleton shows.
*/
function useMarkOpenReportEndOnSkeleton(report: OnyxEntry<OnyxTypes.Report>, isSkeletonVisible: boolean) {
useEffect(() => {
if (!isSkeletonVisible || !report) {
return;
}
markOpenReportEnd(report, {warm: false});
}, [report, isSkeletonVisible]);
}

export default useMarkOpenReportEndOnSkeleton;
162 changes: 162 additions & 0 deletions src/hooks/useReportActionsListModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import {useRoute} from '@react-navigation/native';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import {canUserPerformWriteAction, isReportTransactionThread as isReportTransactionThreadUtil} from '@libs/ReportUtils';
import type {ReportsSplitNavigatorParamList} from '@navigation/types';
import {useConciergeSessionActions, useConciergeSessionState} from '@pages/inbox/ConciergeSessionContext';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import useLoadReportActions from './useLoadReportActions';
import useNetworkWithOfflineStatus from './useNetworkWithOfflineStatus';
import useOnyx from './useOnyx';
import useParentReportAction from './useParentReportAction';
import useReportActionsPagination from './useReportActionsPagination';
import useReportActionsVisibility from './useReportActionsVisibility';
import useReportIsArchived from './useReportIsArchived';

/**
* Single read/derive pipeline for the report-actions list: the subscriptions and derivations the skeleton
* decision and the list render both need, computed once. Side-effect-free (no writes/navigation/telemetry/
* session-start). The guard calls it once and passes `state`/`actions` via `ReportActionsListStateContext`
* and `ReportActionsListActionsContext` so the content doesn't re-subscribe.
*/
function useReportActionsListModel(reportID: string) {
const {isOffline} = useNetworkWithOfflineStatus();
const route = useRoute<PlatformStackRouteProp<ReportsSplitNavigatorParamList, typeof SCREENS.REPORT>>();
const reportActionIDFromRoute = route?.params?.reportActionID;

const [report, reportResult] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

const {
reportActions,
allReportActions,
allReportActionIDs,
hasOlderActions,
hasNewerActions,
sortedAllReportActions,
oldestUnreadReportAction,
transactionThreadReportID,
transactionThreadReport,
parentReportActionForTransactionThread,
treatAsNoPaginationAnchor,
setTreatAsNoPaginationAnchor,
reportPreviewAction,
} = useReportActionsPagination(reportID, reportActionIDFromRoute);

const parentReportAction = useParentReportAction(report);

const [reportLoadingState] = useOnyx(`${ONYXKEYS.COLLECTION.RAM_ONLY_REPORT_LOADING_STATE}${reportID}`);
const isLoadingInitialReportActions = reportLoadingState?.isLoadingInitialReportActions;
const hasOnceLoadedReportActions = reportLoadingState?.hasOnceLoadedReportActions;

const {sessionStartTime, showFullHistory: conciergeShowFullHistory, hadMessagesAtSessionStart: conciergeHadMessagesAtSessionStart} = useConciergeSessionState();
const {setShowFullHistory: setConciergeShowFullHistory, setHadMessagesAtSessionStart: setConciergeHadMessagesAtSessionStart} = useConciergeSessionActions();
const isReportTransactionThread = isReportTransactionThreadUtil(report);

const isReportArchived = useReportIsArchived(reportID);
const canPerformWriteAction = !!canUserPerformWriteAction(report, isReportArchived);

const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);

const [reportPaginationState] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_PAGINATION_STATE}${reportID}`);

const {loadOlderChats, loadNewerChats} = useLoadReportActions({
reportID,
reportActions,
allReportActionIDs,
transactionThreadReportID,
hasOlderActions,
hasNewerActions,
newestFetchedReportActionID: reportPaginationState?.newestFetchedReportActionID,
});

const {
sortedReportActions,
sortedVisibleReportActions,
isConciergeMainDM,
isConciergeHiddenHistory,
showConciergeSidePanelWelcome,
showFullHistory,
hasPreviousMessages,
handleShowPreviousMessages,
} = useReportActionsVisibility({
reportID,
reportActions,
allReportActions,
canPerformWriteAction,
hasOlderActions,
loadOlderChats,
mainDMSessionStartTime: sessionStartTime,
conciergeShowFullHistory: conciergeShowFullHistory || !!reportActionIDFromRoute || !!report?.hasOutstandingChildTask,
setConciergeShowFullHistory,
conciergeHadMessagesAtSessionStart,
setConciergeHadMessagesAtSessionStart,
});

const isMissingReportActions = sortedVisibleReportActions.length === 0;
const isSingleExpenseReport = reportPreviewAction?.childMoneyRequestCount === 1;
// allReportActions excludes the synthetic CREATED action always injected for Concierge, so this is
// false only on a genuinely cold load with no cached history.
const hasCachedReportActions = allReportActions.length > 0;

// Readiness signals for the skeleton decision (some also read by the guard's effect hooks). Off the
// context so their churn (loading, app-load, concierge-session, navigation) never re-renders the list.
const readinessSignals = {
report,
reportResult,
isOffline,
reportActionIDFromRoute,
transactionThreadReport,
isReportArchived,
isReportTransactionThread,
isLoadingInitialReportActions,
hasOnceLoadedReportActions,
isLoadingApp,
reportActionsLength: reportActions.length,
oldestUnreadReportAction,
isSingleExpenseReport,
isMissingReportActions,
isConciergeHiddenHistory,
isConciergeMainDM,
hasCachedReportActions,
showConciergeSidePanelWelcome,
};

// The render state slice on `ReportActionsListStateContext`; this is what drives list re-renders.
// Ambient state (network, route, archived, concierge session) is read locally in the content instead
// of carried here.
const state = {
Comment thread
LukasMod marked this conversation as resolved.
Resolved
report,
hasOnceLoadedReportActions,
hasNewerActions,
sortedAllReportActions,
oldestUnreadReportAction,
transactionThreadReport,
parentReportActionForTransactionThread,
treatAsNoPaginationAnchor,
parentReportAction,
sortedReportActions,
sortedVisibleReportActions,
isConciergeHiddenHistory,
showFullHistory,
hasPreviousMessages,
};

// The command handles on `ReportActionsListActionsContext`. Referentially stable, so actions-only
// consumers don't re-render when the state slice churns.
const actions = {
setTreatAsNoPaginationAnchor,
handleShowPreviousMessages,
loadOlderChats,
loadNewerChats,
};

return {readinessSignals, state, actions};
}

type ReportActionsListModel = ReturnType<typeof useReportActionsListModel>;
type ReportActionsReadinessSignals = ReportActionsListModel['readinessSignals'];
type ReportActionsListState = ReportActionsListModel['state'];
type ReportActionsListActions = ReportActionsListModel['actions'];

export default useReportActionsListModel;
export type {ReportActionsReadinessSignals, ReportActionsListState, ReportActionsListActions};
7 changes: 5 additions & 2 deletions src/hooks/useReportActionsScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ import useReportScrollManager from './useReportScrollManager';
import useScrollToEndOnNewMessageReceived from './useScrollToEndOnNewMessageReceived';

type UseReportActionsScrollParams = {
/** The ID of the report currently being looked at */
reportID: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need to update this hook? Why don't we use report.reportID?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same reasoning as the useMarkAsRead thread: we keep reportID as an explicit non-nullable string because report is an OnyxEntry, so report?.reportID could be undefined.
Here reportID is used on every render (not just in callbacks) to build Onyx subscription keys and the child hooks useReportUnreadMessageScrollTracking / useReportActionsNewActionLiveTail and the scroll resetKey. The hook runs during cold load while report is still undefined, so deriving from report.reportID would build those subscriptions from undefined and force a re-subscribe once report resolves

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe this is worth a comment.


/** The report currently being looked at */
report: OnyxTypes.Report;
report: OnyxEntry<OnyxTypes.Report>;

/** The transaction thread report associated with the current report, if any */
transactionThreadReport: OnyxEntry<OnyxTypes.Report>;
Expand Down Expand Up @@ -112,6 +115,7 @@ type UseReportActionsScrollResult = {
};

function useReportActionsScroll({
reportID,
report,
transactionThreadReport,
parentReportAction,
Expand All @@ -127,7 +131,6 @@ function useReportActionsScroll({
treatAsNoPaginationAnchor,
setTreatAsNoPaginationAnchor,
}: UseReportActionsScrollParams): UseReportActionsScrollResult {
const reportID = report.reportID;
const reportScrollManager = useReportScrollManager();
const {scrollOffsetRef} = useContext(ActionListContext);
const route = useRoute<PlatformStackRouteProp<ReportsSplitNavigatorParamList, typeof SCREENS.REPORT>>();
Expand Down
4 changes: 1 addition & 3 deletions src/hooks/useReportActionsVisibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {isConciergeChatReport} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ReportAction} from '@src/types/onyx';
import type {VisibleReportActionsDerivedValue} from '@src/types/onyx/DerivedValues';
import useConciergeSidePanelReportActions from './useConciergeSidePanelReportActions';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useIsInSidePanel from './useIsInSidePanel';
Expand Down Expand Up @@ -60,10 +59,9 @@ function useReportActionsVisibility({

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [reportVisibleActions] = useOnyx(ONYXKEYS.DERIVED.VISIBLE_REPORT_ACTIONS, {
const [visibleReportActionsData] = useOnyx(ONYXKEYS.DERIVED.VISIBLE_REPORT_ACTIONS, {
selector: reportVisibleActionsSelector(reportID),
});
const visibleReportActionsData: VisibleReportActionsDerivedValue | undefined = reportID && reportVisibleActions ? {[reportID]: reportVisibleActions} : undefined;

const isInSidePanel = useIsInSidePanel();
const isConciergeSidePanel = isInSidePanel && isConciergeChatReport(report, conciergeReportID);
Expand Down
Loading
Loading