Skip to content

Commit

Permalink
More clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-marcellini committed Oct 10, 2023
1 parent d6a8619 commit e7abeff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
3 changes: 0 additions & 3 deletions src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ export default compose(
key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`,
canEvict: false,
},
session: {
key: ONYXKEYS.SESSION,
},
}),
withNetwork(),
)(MoneyRequestAction);
3 changes: 1 addition & 2 deletions src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import reportPropTypes from '../../pages/reportPropTypes';
import * as ReceiptUtils from '../../libs/ReceiptUtils';
import * as ReportActionUtils from '../../libs/ReportActionsUtils';
import * as TransactionUtils from '../../libs/TransactionUtils';
import * as ReportActions from '../../libs/actions/ReportActions';
import ReportActionItemImages from './ReportActionItemImages';
import OfflineWithFeedback from '../OfflineWithFeedback';

Expand Down Expand Up @@ -202,7 +201,7 @@ function ReportPreview(props) {
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20]}>{getPreviewMessage()}</Text>
</View>
{hasErrors && !_.isEmpty(lodashGet(props.iouReport, 'errorFields.createChat')) && (
{hasErrors && (
<Icon
src={Expensicons.DotIndicator}
fill={themeColors.danger}
Expand Down
32 changes: 14 additions & 18 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function buildOnyxDataForMoneyRequest(
iouAction,
optimisticPersonalDetailListAction,
reportPreviewAction,
optimisticRecentlyUsedCategories,
optimisticPolicyRecentlyUsedCategories,
optimisticPolicyRecentlyUsedTags,
isNewChatReport,
isNewIOUReport,
Expand Down Expand Up @@ -190,11 +190,11 @@ function buildOnyxDataForMoneyRequest(
},
];

if (!_.isEmpty(optimisticRecentlyUsedCategories)) {
if (!_.isEmpty(optimisticPolicyRecentlyUsedCategories)) {
optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES}${iouReport.policyID}`,
value: optimisticRecentlyUsedCategories,
value: optimisticPolicyRecentlyUsedCategories,
});
}

Expand Down Expand Up @@ -280,7 +280,7 @@ function buildOnyxDataForMoneyRequest(
},
},
];
const previousPreviewAction = ReportActionsUtils.getReportPreviewAction(chatReport.reportID, iouReport.reportID) || {};

const failureData = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -298,22 +298,19 @@ function buildOnyxDataForMoneyRequest(
: {}),
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`,
value: {
...(isNewIOUReport
? {
...(isNewIOUReport
? [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`,
value: {
errorFields: {
createChat: ErrorUtils.getMicroSecondOnyxError('report.genericCreateReportFailureMessage'),
},
}
: {}),

// If the money request fails to create, reset the report total
...(ReportUtils.isPolicyExpenseChat(chatReport) ? {total: iouReport.total - transaction.amount} : {}),
},
},
},
},
]
: []),
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
Expand All @@ -336,7 +333,6 @@ function buildOnyxDataForMoneyRequest(
}
: {
[reportPreviewAction.reportActionID]: {
previousCreated: previousPreviewAction.created || '',
created: reportPreviewAction.created,
},
}),
Expand Down

0 comments on commit e7abeff

Please sign in to comment.