Skip to content

Commit 1f90068

Browse files
committed
update after merge
1 parent 82b7e8b commit 1f90068

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/libs/API/parameters/OpenReportParams.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
type OpenReportParams = {
22
reportID: string;
3+
reportActionID?: string;
34
emailList?: string;
45
accountIDList?: string;
56
parentReportActionID?: string;

src/pages/home/report/ReportActionsView.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function ReportActionsView({reportActions: allReportActions, ...props}) {
186186
const mostRecentIOUReportActionID = useMemo(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions), [props.reportActions]);
187187
const prevNetworkRef = useRef(props.network);
188188
const prevAuthTokenType = usePrevious(props.session.authTokenType);
189-
const [isInitialLinkedView, setIsInitialLinkedView] = useState(false);
189+
const [isInitialLinkedView, setIsInitialLinkedView] = useState(!!reportActionID);
190190
const prevIsSmallScreenWidthRef = useRef(props.isSmallScreenWidth);
191191
const reportID = props.report.reportID;
192192
const isLoading = (!!reportActionID && props.isLoadingInitialReportActions) || !props.isReadyForCommentLinking;
@@ -430,14 +430,25 @@ function ReportActionsView({reportActions: allReportActions, ...props}) {
430430
const isTheFirstReportActionIsLinked = firstReportActionID === reportActionID;
431431

432432
useEffect(() => {
433+
let timerId;
434+
433435
if (isTheFirstReportActionIsLinked) {
434-
// this should be applied after we navigated to linked reportAction
436+
setIsInitialLinkedView(true);
437+
} else {
438+
// After navigating to the linked reportAction, apply this to correctly set
439+
// `autoscrollToTopThreshold` prop when linking to a specific reportAction.
435440
InteractionManager.runAfterInteractions(() => {
436-
setIsInitialLinkedView(true);
441+
// Using a short delay to ensure the view is updated after interactions
442+
timerId = setTimeout(() => setIsInitialLinkedView(false), 10);
437443
});
438-
} else {
439-
setIsInitialLinkedView(false);
440444
}
445+
446+
return () => {
447+
if (!timerId) {
448+
return;
449+
}
450+
clearTimeout(timerId);
451+
};
441452
}, [isTheFirstReportActionIsLinked]);
442453

443454
// Comments have not loaded at all yet do nothing

0 commit comments

Comments
 (0)