Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix report action is still detected as attachment even after we delete it #24539

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,7 @@ function ReportActionItem(props) {
</ReportActionItemBasicMessage>
);
} else {
const message = _.last(lodashGet(props.action, 'message', [{}]));
const hasBeenFlagged = !_.contains([CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING], moderationDecision);
const isAttachment = _.has(props.action, 'isAttachment') ? props.action.isAttachment : ReportUtils.isReportMessageAttachment(message);
children = (
<ShowContextMenuContext.Provider
value={{
Expand All @@ -329,9 +327,9 @@ function ReportActionItem(props) {
<View style={props.displayAsGroup && hasBeenFlagged ? styles.blockquote : {}}>
<ReportActionItemMessage
action={props.action}
displayAsGroup={props.displayAsGroup}
isHidden={isHidden}
style={[
!props.displayAsGroup && isAttachment ? styles.mt2 : undefined,
_.contains([..._.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG), CONST.REPORT.ACTIONS.TYPE.IOU], props.action.actionName)
? styles.colorMuted
: undefined,
Expand Down
10 changes: 8 additions & 2 deletions src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import _ from 'underscore';
import lodashGet from 'lodash/get';
import styles from '../../../styles/styles';
import ReportActionItemFragment from './ReportActionItemFragment';
import * as ReportUtils from '../../../libs/ReportUtils';
import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
import reportActionPropTypes from './reportActionPropTypes';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
Expand All @@ -13,6 +14,9 @@ const propTypes = {
/** The report action */
action: PropTypes.shape(reportActionPropTypes).isRequired,

/** Should the comment have the appearance of being grouped with the previous comment? */
displayAsGroup: PropTypes.bool.isRequired,

/** Additional styles to add after local styles. */
style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]),

Expand All @@ -29,10 +33,12 @@ const defaultProps = {
};

function ReportActionItemMessage(props) {
const messages = _.compact(props.action.previousMessage || props.action.message);
const isAttachment = ReportUtils.isReportMessageAttachment(_.last(messages));
return (
<View style={[styles.chatItemMessage, ...props.style]}>
<View style={[styles.chatItemMessage, !props.displayAsGroup && isAttachment ? styles.mt2 : {}, ...props.style]}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a minor thing probably, but why was undefined changed to {}? Was there any observable difference in behavior, or is it a stylistic thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a stylistic thing 😄

{!props.isHidden ? (
_.map(_.compact(props.action.previousMessage || props.action.message), (fragment, index) => (
_.map(messages, (fragment, index) => (
<ReportActionItemFragment
key={`actionFragment-${props.action.reportActionID}-${index}`}
fragment={fragment}
Expand Down
Loading