Skip to content

Commit 0dbf5b7

Browse files
mountinyOSBotify
authored andcommitted
Merge pull request #71458 from Expensify/revert-71084-VickyStash/feature/63253-open-transaction-thread-on-top
[CP Staging] Revert "Open transaction thread on top" (cherry picked from commit a1cfa2b) (cherry-picked to staging by mountiny)
1 parent 493b377 commit 0dbf5b7

3 files changed

Lines changed: 13 additions & 33 deletions

File tree

src/pages/home/report/ReportActionsList.tsx

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import {
5353
isExpenseReport,
5454
isInvoiceReport,
5555
isIOUReport,
56-
isMoneyRequestReport,
5756
isTaskReport,
5857
isUnread,
5958
} from '@libs/ReportUtils';
@@ -184,14 +183,9 @@ function ReportActionsList({
184183
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: false});
185184
const isTryNewDotNVPDismissed = !!tryNewDot?.classicRedirect?.dismissed;
186185
const [isScrollToBottomEnabled, setIsScrollToBottomEnabled] = useState(false);
186+
const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(false);
187187
const [actionIdToHighlight, setActionIdToHighlight] = useState('');
188188

189-
const isTransactionThreadReport = useMemo(() => isTransactionThread(parentReportAction), [parentReportAction]);
190-
const isMoneyRequestOrInvoiceReport = useMemo(() => isMoneyRequestReport(report) || isInvoiceReport(report), [report]);
191-
const shouldFocusToTopOnMount = useMemo(() => isTransactionThreadReport || isMoneyRequestOrInvoiceReport, [isMoneyRequestOrInvoiceReport, isTransactionThreadReport]);
192-
const topReportAction = sortedVisibleReportActions.at(-1);
193-
const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(shouldFocusToTopOnMount);
194-
195189
useEffect(() => {
196190
const unsubscribe = Visibility.onVisibilityChange(() => {
197191
setIsVisible(Visibility.isVisible());
@@ -348,9 +342,6 @@ function ReportActionsList({
348342
onTrackScrolling: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
349343
scrollingVerticalOffset.current = event.nativeEvent.contentOffset.y;
350344
onScroll?.(event);
351-
if (shouldScrollToEndAfterLayout) {
352-
setShouldScrollToEndAfterLayout(false);
353-
}
354345
},
355346
});
356347

@@ -400,10 +391,17 @@ function ReportActionsList({
400391
return;
401392
}
402393

394+
const shouldScrollToEnd =
395+
(isExpenseReport(report) || isTransactionThread(parentReportAction)) && isSearchTopmostFullScreenRoute() && hasNewestReportAction && !unreadMarkerReportActionID;
396+
397+
if (shouldScrollToEnd) {
398+
setShouldScrollToEndAfterLayout(true);
399+
}
400+
403401
InteractionManager.runAfterInteractions(() => {
404402
setIsFloatingMessageCounterVisible(false);
405403

406-
if (!shouldScrollToEndAfterLayout) {
404+
if (!shouldScrollToEnd) {
407405
reportScrollManager.scrollToBottom();
408406
}
409407
});
@@ -721,9 +719,8 @@ function ReportActionsList({
721719
setIsScrollToBottomEnabled(false);
722720
}
723721
if (shouldScrollToEndAfterLayout) {
724-
InteractionManager.runAfterInteractions(() => {
725-
reportScrollManager.scrollToEnd();
726-
});
722+
reportScrollManager.scrollToEnd();
723+
setShouldScrollToEndAfterLayout(false);
727724
}
728725
},
729726
[isScrollToBottomEnabled, onLayout, reportScrollManager, shouldScrollToEndAfterLayout],
@@ -759,13 +756,6 @@ function ReportActionsList({
759756
return <ReportActionsSkeletonView shouldAnimate={false} />;
760757
}, [shouldShowSkeleton]);
761758

762-
const renderTopReportAction = () => (
763-
<>
764-
{!shouldShowReportRecipientLocalTime && !hideComposer ? <View style={[styles.stickToBottom, styles.appBG, styles.zIndex10, styles.height4]} /> : undefined}
765-
<View style={styles.pt4}>{renderItem({item: topReportAction, index: sortedVisibleReportActions.length - 1} as ListRenderItemInfo<OnyxTypes.ReportAction>)}</View>
766-
</>
767-
);
768-
769759
const onStartReached = useCallback(() => {
770760
if (!isSearchTopmostFullScreenRoute()) {
771761
loadNewerChats(false);
@@ -790,7 +780,6 @@ function ReportActionsList({
790780
style={[styles.flex1, !shouldShowReportRecipientLocalTime && !hideComposer ? styles.pb4 : {}]}
791781
fsClass={reportActionsListFSClass}
792782
>
793-
{shouldScrollToEndAfterLayout && topReportAction ? renderTopReportAction() : undefined}
794783
<InvertedFlatList
795784
accessibilityLabel={translate('sidebarScreen.listOfChatMessages')}
796785
ref={reportScrollManager.ref}
@@ -799,11 +788,7 @@ function ReportActionsList({
799788
data={sortedVisibleReportActions}
800789
renderItem={renderItem}
801790
renderScrollComponent={renderActionSheetAwareScrollView}
802-
contentContainerStyle={[
803-
styles.chatContentScrollView,
804-
shouldScrollToEndAfterLayout ? styles.opacity0 : styles.opacity1,
805-
shouldFocusToTopOnMount ? styles.justifyContentEnd : undefined,
806-
]}
791+
contentContainerStyle={styles.chatContentScrollView}
807792
keyExtractor={keyExtractor}
808793
initialNumToRender={initialNumToRender}
809794
onEndReached={onEndReached}

src/pages/home/report/ReportActionsView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ function ReportActionsView({
9797
[getTransactionThreadReportActions],
9898
);
9999
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, {canBeMissing: true});
100-
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`, {canBeMissing: true, allowStaleData: true});
101100
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
102101
const prevTransactionThreadReport = usePrevious(transactionThreadReport);
103102
const reportActionID = route?.params?.reportActionID;
@@ -292,7 +291,7 @@ function ReportActionsView({
292291
}, [isTheFirstReportActionIsLinked]);
293292

294293
// Show skeleton while loading initial report actions when data is incomplete/missing and online
295-
const shouldShowSkeletonForInitialLoad = isLoadingInitialReportActions && (isReportDataIncomplete || isMissingReportActions || !reportMetadata?.hasOnceLoadedReportActions) && !isOffline;
294+
const shouldShowSkeletonForInitialLoad = isLoadingInitialReportActions && (isReportDataIncomplete || isMissingReportActions) && !isOffline;
296295

297296
// Show skeleton while the app is loading and we're online
298297
const shouldShowSkeletonForAppLoad = isLoadingApp && !isOffline;

src/styles/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,10 +3277,6 @@ const staticStyles = (theme: ThemeColors) =>
32773277
zIndex: 10,
32783278
},
32793279

3280-
height4: {
3281-
height: 16,
3282-
},
3283-
32843280
searchListContentContainerStyles: {
32853281
paddingTop: variables.searchListContentMarginTop,
32863282
},

0 commit comments

Comments
 (0)