diff --git a/src/components/ArchivedReportFooter.js b/src/components/ArchivedReportFooter.js
index af5be5de4d1a..bcb204c98369 100644
--- a/src/components/ArchivedReportFooter.js
+++ b/src/components/ArchivedReportFooter.js
@@ -1,24 +1,37 @@
+import lodashGet from 'lodash/get';
import React from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
+import CONST from '../CONST';
import Banner from './Banner';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import compose from '../libs/compose';
import personalDetailsPropType from '../pages/personalDetailsPropType';
import ONYXKEYS from '../ONYXKEYS';
import * as ReportUtils from '../libs/ReportUtils';
-import reportActionPropTypes from '../pages/home/report/reportActionPropTypes';
const propTypes = {
+ /** The reason this report was archived */
+ reportClosedAction: PropTypes.shape({
+ /** Message attached to the report closed action */
+ originalMessage: PropTypes.shape({
+ /** The reason the report was closed */
+ reason: PropTypes.string.isRequired,
+
+ /** (For accountMerged reason only), the email of the previous owner of this report. */
+ oldLogin: PropTypes.string,
+
+ /** (For accountMerged reason only), the email of the account the previous owner was merged into */
+ newLogin: PropTypes.string,
+ }).isRequired,
+ }),
+
/** The archived report */
report: PropTypes.shape({
- /** The email of the owner of the report */
- ownerEmail: PropTypes.string,
+ /** The policy this report is attached to */
+ policyID: PropTypes.string,
}).isRequired,
- /** Array of report actions for this report */
- reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)).isRequired,
-
/** Personal details of all users */
personalDetails: PropTypes.objectOf(personalDetailsPropType).isRequired,
@@ -31,14 +44,40 @@ const propTypes = {
...withLocalizePropTypes,
};
+const defaultProps = {
+ reportClosedAction: {
+ originalMessage: {
+ reason: CONST.REPORT.ARCHIVE_REASON.DEFAULT,
+ },
+ },
+};
+
const ArchivedReportFooter = (props) => {
- const archivedText = ReportUtils.getArchivedText(props.report, props.reportActions, props.personalDetails, props.policies);
+ const archiveReason = lodashGet(props.reportClosedAction, 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
+ let displayName = lodashGet(props.personalDetails, `${props.report.ownerEmail}.displayName`, props.report.ownerEmail);
+
+ let oldDisplayName;
+ if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) {
+ const newLogin = props.reportClosedAction.originalMessage.newLogin;
+ const oldLogin = props.reportClosedAction.originalMessage.oldLogin;
+ displayName = lodashGet(props.personalDetails, `${newLogin}.displayName`, newLogin);
+ oldDisplayName = lodashGet(props.personalDetails, `${oldLogin}.displayName`, oldLogin);
+ }
+
return (
-
+ ${displayName}`,
+ oldDisplayName: `${oldDisplayName}`,
+ policyName: `${ReportUtils.getPolicyName(props.report, props.policies)}`,
+ })}
+ shouldRenderHTML={archiveReason !== CONST.REPORT.ARCHIVE_REASON.DEFAULT}
+ />
);
};
ArchivedReportFooter.propTypes = propTypes;
+ArchivedReportFooter.defaultProps = defaultProps;
ArchivedReportFooter.displayName = 'ArchivedReportFooter';
export default compose(
diff --git a/src/components/Banner.js b/src/components/Banner.js
index a4ea17eec2c8..87808c22af24 100644
--- a/src/components/Banner.js
+++ b/src/components/Banner.js
@@ -5,13 +5,21 @@ import Hoverable from './Hoverable';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import RenderHTML from './RenderHTML';
+import Text from './Text';
import styles from '../styles/styles';
import * as StyleUtils from '../styles/StyleUtils';
import getButtonState from '../libs/getButtonState';
const propTypes = {
- /** HTML to display in the banner. */
- html: PropTypes.string.isRequired,
+ /** Text to display in the banner. */
+ text: PropTypes.string.isRequired,
+
+ /** Should this component render the text as HTML? */
+ shouldRenderHTML: PropTypes.bool,
+};
+
+const defaultProps = {
+ shouldRenderHTML: false,
};
const Banner = props => (
@@ -32,13 +40,18 @@ const Banner = props => (
fill={StyleUtils.getIconFillColor(getButtonState(isHovered))}
/>
-
+ {
+ props.shouldRenderHTML
+ ?
+ : {props.text}
+ }
)}
);
Banner.propTypes = propTypes;
+Banner.defaultProps = defaultProps;
Banner.displayName = 'Banner';
export default memo(Banner);
diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js
index 72cf9bc3ad60..631d80fd9b51 100644
--- a/src/components/ReportWelcomeText.js
+++ b/src/components/ReportWelcomeText.js
@@ -13,7 +13,6 @@ import ONYXKEYS from '../ONYXKEYS';
import Navigation from '../libs/Navigation/Navigation';
import ROUTES from '../ROUTES';
import Tooltip from './Tooltip';
-import RenderHTML from './RenderHTML';
const personalDetailsPropTypes = PropTypes.shape({
/** The login of the person (either email or phone number) */
@@ -33,7 +32,7 @@ const propTypes = {
/* Onyx Props */
- /** All the personal details for everyone */
+ /** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes).isRequired,
/** The policies which the user has access to and which the report could be tied to */
@@ -53,8 +52,6 @@ const ReportWelcomeText = (props) => {
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report);
const isChatRoom = ReportUtils.isChatRoom(props.report);
const isDefault = !(isChatRoom || isPolicyExpenseChat);
- const isArchivedRoom = ReportUtils.isArchivedRoom(props.report);
- const reportArchivedText = ReportUtils.getArchivedText(props.report, props.reportActions, props.personalDetails, props.policies);
const participants = lodashGet(props.report, 'participants', []);
const isMultipleParticipant = participants.length > 1;
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(
@@ -65,29 +62,25 @@ const ReportWelcomeText = (props) => {
return (
{isPolicyExpenseChat && (
- isArchivedRoom
- ?
- : (
- <>
- {/* Add align center style individually because of limited style inheritance in React Native https://reactnative.dev/docs/text#limited-style-inheritance */}
-
- {props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')}
-
-
- {/* Use the policyExpenseChat owner's first name or their email if it's undefined or an empty string */}
- {lodashGet(props.personalDetails, [props.report.ownerEmail, 'firstName']) || props.report.ownerEmail}
-
-
- {props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')}
-
-
- {ReportUtils.getPolicyName(props.report, props.policies)}
-
-
- {props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree')}
-
- >
- )
+ <>
+ {/* Add align center style individually because of limited style inheritance in React Native https://reactnative.dev/docs/text#limited-style-inheritance */}
+
+ {props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')}
+
+
+ {/* Use the policyExpenseChat owner's first name or their email if it's undefined or an empty string */}
+ {lodashGet(props.personalDetails, [props.report.ownerEmail, 'firstName']) || props.report.ownerEmail}
+
+
+ {props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')}
+
+
+ {ReportUtils.getPolicyName(props.report, props.policies)}
+
+
+ {props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree')}
+
+ >
)}
{isChatRoom && (
<>
@@ -143,9 +136,5 @@ export default compose(
policies: {
key: ONYXKEYS.COLLECTION.POLICY,
},
- reportActions: {
- key: props => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${props.report.reportID}`,
- canEvict: false,
- },
}),
)(ReportWelcomeText);
diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js
index 3add040e848a..0a47f9693fe3 100644
--- a/src/libs/ReportUtils.js
+++ b/src/libs/ReportUtils.js
@@ -1,7 +1,6 @@
import _ from 'underscore';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
-import lodashFindLast from 'lodash/findLast';
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
@@ -503,42 +502,6 @@ function navigateToDetailsPage(report) {
Navigation.navigate(ROUTES.getReportParticipantsRoute(report.reportID));
}
-/**
- * Get the text explaining why a report was archived.
- *
- * @param {Object} report
- * @param {Object} reportActions
- * @param {Object} personalDetails
- * @param {Object} policies
- * @returns {String|null}
- */
-function getArchivedText(report, reportActions, personalDetails, policies) {
- if (!isArchivedRoom(report)) {
- return Localize.translateLocal(`reportArchiveReasons.${CONST.REPORT.ARCHIVE_REASON.DEFAULT}`);
- }
-
- const reportClosedAction = lodashFindLast(reportActions, action => action.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED);
- if (!reportClosedAction) {
- return Localize.translateLocal(`reportArchiveReasons.${CONST.REPORT.ARCHIVE_REASON.DEFAULT}`);
- }
-
- const archiveReason = lodashGet(reportClosedAction, 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
- let displayName = lodashGet(personalDetails, `${report.ownerEmail}.displayName`, report.ownerEmail);
- let oldDisplayName;
- if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) {
- const newLogin = reportClosedAction.originalMessage.newLogin;
- const oldLogin = reportClosedAction.originalMessage.oldLogin;
- displayName = lodashGet(personalDetails, `${newLogin}.displayName`, newLogin);
- oldDisplayName = lodashGet(personalDetails, `${oldLogin}.displayName`, oldLogin);
- }
-
- return Localize.translateLocal(`reportArchiveReasons.${archiveReason}`, {
- displayName: `${displayName}`,
- oldDisplayName: `${oldDisplayName}`,
- policyName: `${getPolicyName(report, policies)}`,
- });
-}
-
export {
getReportParticipantsTitle,
isReportMessageAttachment,
@@ -566,5 +529,4 @@ export {
getDisplayNamesWithTooltips,
getReportName,
navigateToDetailsPage,
- getArchivedText,
};
diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js
index a0cb67ffbbeb..d03dca98fcd5 100644
--- a/src/pages/home/ReportScreen.js
+++ b/src/pages/home/ReportScreen.js
@@ -3,6 +3,7 @@ import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import {Keyboard, View} from 'react-native';
import _ from 'underscore';
+import lodashFindLast from 'lodash/findLast';
import styles from '../../styles/styles';
import ScreenWrapper from '../../components/ScreenWrapper';
import HeaderView from './HeaderView';
@@ -172,7 +173,13 @@ class ReportScreen extends React.Component {
}
const reportID = getReportID(this.props.route);
+
const isArchivedRoom = ReportUtils.isArchivedRoom(this.props.report);
+ let reportClosedAction;
+ if (isArchivedRoom) {
+ reportClosedAction = lodashFindLast(this.props.reportActions, action => action.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED);
+ }
+
return (
) : (
diff --git a/src/stories/Banner.stories.js b/src/stories/Banner.stories.js
index 99de89c94490..247489d49711 100644
--- a/src/stories/Banner.stories.js
+++ b/src/stories/Banner.stories.js
@@ -18,12 +18,13 @@ const Template = args => ;
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const InfoBanner = Template.bind({});
InfoBanner.args = {
- html: 'This is an informational banner',
+ text: 'This is an informational banner',
};
const HTMLBanner = Template.bind({});
HTMLBanner.args = {
- html: 'This is a informational banner containing HTML',
+ text: 'This is a informational banner containing HTML',
+ shouldRenderHTML: true,
};
export default story;