diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 83fae8287c74..b2a3d411800e 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -40,6 +40,12 @@ Onyx.connect({ }, }); +let loginList; +Onyx.connect({ + key: ONYXKEYS.LOGIN_LIST, + callback: (val) => (loginList = _.isEmpty(val) ? [] : _.keys(val)), +}); + let preferredLocale = CONST.LOCALES.DEFAULT; Onyx.connect({ key: ONYXKEYS.NVP_PREFERRED_LOCALE, @@ -220,7 +226,7 @@ function canEditReportAction(reportAction) { */ function canFlagReportAction(reportAction) { return ( - reportAction.actorEmail !== sessionEmail && + !loginList.includes(reportAction.actorEmail) && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !ReportActionsUtils.isDeletedAction(reportAction) && !ReportActionsUtils.isCreatedTaskReportAction(reportAction) @@ -2029,6 +2035,24 @@ function chatIncludesChronos(report) { return report.participantAccountIDs && _.contains(report.participantAccountIDs, CONST.ACCOUNT_ID.CHRONOS); } +/** + * Whether flag comment page should show + * + * @param {Object} reportAction + * @param {Object} report + * @returns {Boolean} + */ + +function shouldShowFlagComment(reportAction, report) { + return ( + canFlagReportAction(reportAction) && + !isArchivedRoom(report) && + !chatIncludesChronos(report) && + !isConciergeChatReport(report.reportID) && + reportAction.actorEmail !== CONST.EMAIL.CONCIERGE + ); +} + /** * @param {Object} report * @param {String} report.lastReadTime @@ -2275,6 +2299,7 @@ export { findLastAccessedReport, canEditReportAction, canFlagReportAction, + shouldShowFlagComment, canDeleteReportAction, canLeaveRoom, sortReportsByLastRead, diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 568f6073a76e..4c602f15c5fd 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -20,6 +20,8 @@ import CONST from '../CONST'; import * as ReportUtils from '../libs/ReportUtils'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; import * as Session from '../libs/actions/Session'; +import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; +import FullscreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; const propTypes = { /** Array of report actions for this report */ @@ -39,12 +41,16 @@ const propTypes = { }), }).isRequired, + /** Indicates whether the report data is loading */ + isLoadingReportData: PropTypes.bool, + ...withLocalizePropTypes, }; const defaultProps = { reportActions: {}, report: {}, + isLoadingReportData: true, }; /** @@ -61,6 +67,11 @@ function getReportID(route) { function FlagCommentPage(props) { let reportAction = props.reportActions[`${props.route.params.reportActionID.toString()}`]; + + // Handle threads if needed + if (reportAction === undefined || reportAction.reportActionID === undefined) { + reportAction = ReportActionsUtils.getParentReportAction(props.report); + } const severities = [ { severity: CONST.MODERATION.FLAG_SEVERITY_SPAM, @@ -118,7 +129,6 @@ function FlagCommentPage(props) { // Handle threads if needed if (reportAction === undefined || reportAction.reportActionID === undefined) { reportID = ReportUtils.getParentReport(props.report).reportID; - reportAction = ReportActionsUtils.getParentReportAction(props.report); } Report.flagComment(reportID, reportAction, severity); Navigation.dismissModal(); @@ -138,10 +148,15 @@ function FlagCommentPage(props) { /> )); + const shouldShowLoading = props.isLoadingReportData || props.report.isLoadingReportActions; + if (shouldShowLoading) { + return ; + } + return ( {({safeAreaPaddingBottomStyle}) => ( - <> + {props.translate('moderation.chooseAReason')} {severityMenuItems} - + )} ); @@ -175,5 +190,8 @@ export default compose( report: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`, }, + isLoadingReportData: { + key: ONYXKEYS.IS_LOADING_REPORT_DATA, + }, }), )(FlagCommentPage);