diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 6c6421593837d..47d2ad356dadf 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -13,7 +13,6 @@ import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; -import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as Report from '@userActions/Report'; import * as Session from '@userActions/Session'; @@ -43,10 +42,15 @@ const propTypes = { }).isRequired, ...withLocalizePropTypes, + + /* Onyx Props */ + /** All the report actions from the parent report */ + parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), }; const defaultProps = { reportActions: {}, + parentReportActions: {}, report: {}, }; @@ -120,18 +124,19 @@ function FlagCommentPage(props) { // Handle threads if needed if (reportAction === undefined || reportAction.reportActionID === undefined) { - reportAction = ReportActionsUtils.getParentReportAction(props.report); + reportAction = props.parentReportActions[props.report.parentReportActionID] || {}; } return reportAction; - }, [props.report, props.reportActions, props.route.params.reportActionID]); + }, [props.report, props.reportActions, props.route.params.reportActionID, props.parentReportActions]); const flagComment = (severity) => { let reportID = getReportID(props.route); const reportAction = getActionToFlag(); + const parentReportAction = props.parentReportActions[props.report.parentReportActionID] || {}; // Handle threads if needed - if (ReportUtils.isChatThread(props.report) && reportAction.reportActionID === ReportActionsUtils.getParentReportAction(props.report).reportActionID) { + if (ReportUtils.isChatThread(props.report) && reportAction.reportActionID === parentReportAction.reportActionID) { reportID = ReportUtils.getParentReport(props.report).reportID; }