diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js
index c8e40e636b58..ceec76c279c6 100644
--- a/src/components/ReportActionItem/IOUPreview.js
+++ b/src/components/ReportActionItem/IOUPreview.js
@@ -1,7 +1,6 @@
import React from 'react';
import {
View,
- ActivityIndicator,
TouchableWithoutFeedback,
} from 'react-native';
import PropTypes from 'prop-types';
@@ -34,6 +33,7 @@ const propTypes = {
onPayButtonPressed: PropTypes.func,
/** The active IOUReport, used for Onyx subscription */
+ // eslint-disable-next-line react/no-unused-prop-types
iouReportID: PropTypes.string.isRequired,
/** The associated chatReport */
@@ -117,11 +117,6 @@ const IOUPreview = (props) => {
// Pay button should only be visible to the manager of the report.
const isCurrentUserManager = managerEmail === sessionEmail;
- const reportIsLoading = _.isEmpty(props.iouReport);
-
- if (reportIsLoading) {
- Report.fetchIOUReportByID(props.iouReportID, props.chatReportID);
- }
const managerName = lodashGet(props.personalDetails, [managerEmail, 'firstName'], '')
|| Str.removeSMSDomain(managerEmail);
@@ -137,72 +132,68 @@ const IOUPreview = (props) => {
return (
- {reportIsLoading
- ?
- : (
- {
- PaymentMethods.clearWalletTermsError();
- Report.clearIOUError(props.chatReportID);
- }}
- errorRowStyles={[styles.mbn1]}
- >
-
-
-
-
- {cachedTotal}
-
- {!props.iouReport.hasOutstandingIOU && (
-
-
-
- )}
+ {
+ PaymentMethods.clearWalletTermsError();
+ Report.clearIOUError(props.chatReportID);
+ }}
+ errorRowStyles={[styles.mbn1]}
+ >
+
+
+
+
+ {cachedTotal}
+
+ {!props.iouReport.hasOutstandingIOU && (
+
+
-
-
-
-
- {isCurrentUserManager
- ? (
-
- {props.iouReport.hasOutstandingIOU
- ? props.translate('iou.youowe', {owner: ownerName})
- : props.translate('iou.youpaid', {owner: ownerName})}
-
- )
- : (
-
- {props.iouReport.hasOutstandingIOU
- ? props.translate('iou.owesyou', {manager: managerName})
- : props.translate('iou.paidyou', {manager: managerName})}
-
- )}
- {(isCurrentUserManager
- && !props.shouldHidePayButton
- && props.iouReport.stateNum === CONST.REPORT.STATE_NUM.PROCESSING && (
-
- ))}
+ )}
+
+
+
-
- )}
+
+ {isCurrentUserManager
+ ? (
+
+ {props.iouReport.hasOutstandingIOU
+ ? props.translate('iou.youowe', {owner: ownerName})
+ : props.translate('iou.youpaid', {owner: ownerName})}
+
+ )
+ : (
+
+ {props.iouReport.hasOutstandingIOU
+ ? props.translate('iou.owesyou', {manager: managerName})
+ : props.translate('iou.paidyou', {manager: managerName})}
+
+ )}
+ {(isCurrentUserManager
+ && !props.shouldHidePayButton
+ && props.iouReport.stateNum === CONST.REPORT.STATE_NUM.PROCESSING && (
+
+ ))}
+
+
);
diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js
index eec536422004..1c8b09968287 100644
--- a/src/libs/actions/Report.js
+++ b/src/libs/actions/Report.js
@@ -12,15 +12,12 @@ import Navigation from '../Navigation/Navigation';
import * as ActiveClientManager from '../ActiveClientManager';
import Visibility from '../Visibility';
import ROUTES from '../../ROUTES';
-import * as DeprecatedAPI from '../deprecatedAPI';
import * as API from '../API';
import CONFIG from '../../CONFIG';
import CONST from '../../CONST';
import Log from '../Log';
import * as LoginUtils from '../LoginUtils';
import * as ReportUtils from '../ReportUtils';
-import Growl from '../Growl';
-import * as Localize from '../Localize';
import DateUtils from '../DateUtils';
import * as ReportActionsUtils from '../ReportActionsUtils';
import * as OptionsListUtils from '../OptionsListUtils';
@@ -181,76 +178,6 @@ function getSimplifiedIOUReport(reportData, chatReportID) {
};
}
-/**
- * Given IOU and chat report ID fetches most recent IOU data from DeprecatedAPI.
- *
- * @param {Number} iouReportID
- * @param {Number} chatReportID
- * @returns {Promise}
- */
-function fetchIOUReport(iouReportID, chatReportID) {
- return DeprecatedAPI.Get({
- returnValueList: 'reportStuff',
- reportIDList: iouReportID,
- shouldLoadOptionalKeys: true,
- includePinnedReports: true,
- }).then((response) => {
- if (!response) {
- return;
- }
- if (response.jsonCode !== 200) {
- console.error(response.message);
- return;
- }
- const iouReportData = response.reports[iouReportID];
- if (!iouReportData) {
- // IOU data for a report will be missing when the IOU report has already been paid.
- // This is expected and we return early as no further processing can be done.
- return;
- }
- return getSimplifiedIOUReport(iouReportData, chatReportID);
- }).catch((error) => {
- Log.hmmm('[Report] Failed to populate IOU Collection:', error.message);
- });
-}
-
-/**
- * Given IOU object, save the data to Onyx.
- *
- * @param {Object} iouReportObject
- * @param {Number} iouReportObject.stateNum
- * @param {Number} iouReportObject.total
- * @param {Number} iouReportObject.reportID
- */
-function setLocalIOUReportData(iouReportObject) {
- const iouReportKey = `${ONYXKEYS.COLLECTION.REPORT}${iouReportObject.reportID}`;
- Onyx.merge(iouReportKey, iouReportObject);
-}
-
-/**
- * Fetch the iouReport and persist the data to Onyx.
- *
- * @param {Number} iouReportID - ID of the report we are fetching
- * @param {Number} chatReportID - associated chatReportID, set as an iouReport field
- * @param {Boolean} [shouldRedirectIfEmpty=false] - Whether to redirect to Active Report Screen if IOUReport is empty
- * @returns {Promise}
- */
-function fetchIOUReportByID(iouReportID, chatReportID, shouldRedirectIfEmpty = false) {
- return fetchIOUReport(iouReportID, chatReportID)
- .then((iouReportObject) => {
- if (!iouReportObject && shouldRedirectIfEmpty) {
- Growl.error(Localize.translateLocal('notFound.iouReportNotFound'));
- Navigation.navigate(ROUTES.REPORT);
- return;
- }
- if (!iouReportObject) {
- return;
- }
- setLocalIOUReportData(iouReportObject);
- return iouReportObject;
- });
-}
-
/**
* Get the private pusher channel name for a Report.
*
@@ -1416,7 +1343,6 @@ Onyx.connect({
});
export {
- fetchIOUReportByID,
addComment,
addAttachment,
reconnect,
@@ -1431,7 +1357,6 @@ export {
handleUserDeletedLinks,
saveReportActionDraft,
deleteReportComment,
- getSimplifiedIOUReport,
syncChatAndIOUReports,
navigateToConciergeChat,
setReportWithDraft,
diff --git a/src/pages/iou/IOUDetailsModal.js b/src/pages/iou/IOUDetailsModal.js
index 0d45271ab5b1..8dc72c5aba6b 100644
--- a/src/pages/iou/IOUDetailsModal.js
+++ b/src/pages/iou/IOUDetailsModal.js
@@ -147,7 +147,6 @@ class IOUDetailsModal extends Component {