Skip to content

Commit

Permalink
Merge pull request #24539 from bernhardoj/fix/24216-still-detected-as…
Browse files Browse the repository at this point in the history
…-attachment-after-delete

Fix report action is still detected as attachment even after we delete it
  • Loading branch information
Li357 authored Aug 16, 2023
2 parents 043b1ed + 33f1f60 commit bfe5c21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ function ReportActionItem(props) {
} else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) {
children = <ReportActionItemBasicMessage message={ReportUtils.getModifiedExpenseMessage(props.action)} />;
} 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 @@ -340,9 +338,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]}>
{!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

0 comments on commit bfe5c21

Please sign in to comment.