Skip to content

Commit

Permalink
Merge pull request #32653 from rezkiy37/fix/32565-deprecate-hasOutsta…
Browse files Browse the repository at this point in the history
…ndingIOU-key
  • Loading branch information
mountiny authored Dec 11, 2023
2 parents e1d334a + 9939213 commit 86a2521
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 130 deletions.
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function MoneyRequestAction({
if (
!_.isEmpty(iouReport) &&
!_.isEmpty(reportActions) &&
chatReport.hasOutstandingIOU &&
chatReport.iouReportID &&
isMostRecentIOUReportAction &&
action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD &&
network.isOffline
Expand Down
3 changes: 0 additions & 3 deletions src/components/ReportActionItem/MoneyRequestPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ const propTypes = {

/** Currency of outstanding amount of this transaction */
currency: PropTypes.string,

/** Does the iouReport have an outstanding IOU? */
hasOutstandingIOU: PropTypes.bool,
}),

/** True if this is this IOU is a split instead of a 1:1 request */
Expand Down
3 changes: 0 additions & 3 deletions src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ const propTypes = {
/** Currency of outstanding amount of this transaction */
currency: PropTypes.string,

/** Does the iouReport have an outstanding IOU? */
hasOutstandingIOU: PropTypes.bool,

/** Is the iouReport waiting for the submitter to add a credit bank account? */
isWaitingOnBankAccount: PropTypes.bool,
}),
Expand Down
3 changes: 0 additions & 3 deletions src/components/optionPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ export default PropTypes.shape({
// Whether the report corresponds to a chat room
isChatRoom: PropTypes.bool,

// Whether the option has an outstanding IOU
hasOutstandingIOU: PropTypes.bool,

// Custom icon to render on the right side of the option
customIcon: PropTypes.shape({
// The icon source
Expand Down
27 changes: 0 additions & 27 deletions src/libs/E2E/apiMocks/openApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,6 @@ const openApp = (): Response => ({
'<a href="mailto:applause.expensifail.com@expensify.cash" target="_blank" rel="noreferrer noopener">applause.expensifail.com@expensify.cash</a>. Learn more ' +
'<a href="https://www.expensify.com/inbox?policyID=C28C2634DD7226B8&amp;taskID=ForwardToExpensifyCash" target="_blank" rel="noreferrer noopener">here.' +
'</a> For questions, just reply to this message.',
hasOutstandingIOU: false,
},
report_98258458: {
reportID: '98258458',
Expand All @@ -1549,7 +1548,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: true,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_98344717: {
reportID: '98344717',
Expand All @@ -1571,7 +1569,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Requested \u20b41.67 from applausetester+perf2@applause.expensifail.com',
hasOutstandingIOU: false,
},
report_98345050: {
reportID: '98345050',
Expand All @@ -1593,7 +1590,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Cancelled the \u20b440.00 request',
hasOutstandingIOU: false,
},
report_98345315: {
reportID: '98345315',
Expand All @@ -1615,7 +1611,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: '<a href="mailto:applausetester+perf2@applause.expensifail.com">applausetester+perf2@applause.expensifail.com</a>',
hasOutstandingIOU: false,
},
report_98345625: {
reportID: '98345625',
Expand All @@ -1637,7 +1632,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Say hello\ud83d\ude10',
hasOutstandingIOU: false,
},
report_98345679: {
reportID: '98345679',
Expand All @@ -1659,7 +1653,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: true,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_98414813: {
reportID: '98414813',
Expand All @@ -1681,7 +1674,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Split \u20b45.00 with applausetester+perf2@applause.expensifail.com and fake6@gmail.com',
hasOutstandingIOU: false,
},
report_98817646: {
reportID: '98817646',
Expand All @@ -1703,7 +1695,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'RR',
hasOutstandingIOU: true,
iouReportID: '2543745284790730',
},
report_358751490033727: {
Expand All @@ -1726,7 +1717,6 @@ const openApp = (): Response => ({
visibility: 'restricted',
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'STAGING_CHAT_MESSAGE_A2C534B7-3509-416E-A0AD-8463831C29DD',
hasOutstandingIOU: false,
},
report_663424408122117: {
reportID: '663424408122117',
Expand All @@ -1748,7 +1738,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_944123936554214: {
reportID: '944123936554214',
Expand All @@ -1770,7 +1759,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: true,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_2242399088152511: {
reportID: '2242399088152511',
Expand All @@ -1792,7 +1780,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: '<p>Hi there, thanks for reaching out! How may I help?</p>',
hasOutstandingIOU: false,
},
report_2576922422943214: {
reportID: '2576922422943214',
Expand All @@ -1814,7 +1801,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Test',
hasOutstandingIOU: false,
},
report_2752461403207161: {
reportID: '2752461403207161',
Expand All @@ -1836,7 +1822,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_3785654888638968: {
reportID: '3785654888638968',
Expand All @@ -1858,7 +1843,6 @@ const openApp = (): Response => ({
visibility: 'restricted',
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Room renamed to #jack',
hasOutstandingIOU: false,
},
report_4867098979334014: {
reportID: '4867098979334014',
Expand All @@ -1880,7 +1864,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Requested \u20ac200.00 from Christoph for Essen mit Kunden',
hasOutstandingIOU: true,
iouReportID: '4249286573496381',
},
report_5277760851229035: {
Expand All @@ -1905,7 +1888,6 @@ const openApp = (): Response => ({
lastMessageHtml:
'fff<br />f<br />f<br />f<br />f<br />f<br />f<br />f<br />f<br /><br />f<br />f<br />f<br />f<br /><br />f<br />' +
'f<br />f<br />f<br />f<br />f<br /><br />f<br />f<br />f<br />f<br />f<br />ff',
hasOutstandingIOU: false,
},
report_5324367938904284: {
reportID: '5324367938904284',
Expand All @@ -1927,7 +1909,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Iviviviv8b',
hasOutstandingIOU: false,
},
report_5654270288238256: {
reportID: '5654270288238256',
Expand All @@ -1949,7 +1930,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_6194900075541844: {
reportID: '6194900075541844',
Expand All @@ -1971,7 +1951,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_6801643744224146: {
reportID: '6801643744224146',
Expand All @@ -1994,7 +1973,6 @@ const openApp = (): Response => ({
isOwnPolicyExpenseChat: false,
lastMessageHtml:
"\ud83d\udc4b Welcome to Expensify! I'm Concierge. Is there anything I can help with? Click the + icon on the homescreen to explore the features you can use.",
hasOutstandingIOU: false,
},
report_7658708888047100: {
reportID: '7658708888047100',
Expand All @@ -2016,7 +1994,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Hi there! How can I help?\u00a0',
hasOutstandingIOU: false,
},
report_7756405299640824: {
reportID: '7756405299640824',
Expand All @@ -2038,7 +2015,6 @@ const openApp = (): Response => ({
visibility: 'restricted',
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'Room renamed to #jackd23',
hasOutstandingIOU: false,
},
report_7819732651025410: {
reportID: '7819732651025410',
Expand All @@ -2060,7 +2036,6 @@ const openApp = (): Response => ({
visibility: null,
isOwnPolicyExpenseChat: false,
lastMessageHtml: '',
hasOutstandingIOU: false,
},
report_2543745284790730: {
reportID: '2543745284790730',
Expand All @@ -2072,7 +2047,6 @@ const openApp = (): Response => ({
cachedTotal: '($1,473.11)',
total: 147311,
stateNum: 1,
hasOutstandingIOU: true,
},
report_4249286573496381: {
reportID: '4249286573496381',
Expand All @@ -2084,7 +2058,6 @@ const openApp = (): Response => ({
cachedTotal: '($212.78)',
total: 21278,
stateNum: 1,
hasOutstandingIOU: true,
},
},
},
Expand Down
1 change: 0 additions & 1 deletion src/libs/E2E/apiMocks/openReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default (): Response => ({
isOwnPolicyExpenseChat: false,
lastMessageHtml: 'terry+hightraffic@margelo.io owes \u20ac12.00',
iouReportID: '206636935813547',
hasOutstandingIOU: false,
hasOutstandingChildRequest: false,
policyName: null,
hasParentAccess: null,
Expand Down
2 changes: 0 additions & 2 deletions src/libs/IOUUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ function updateIOUOwnerAndTotal(iouReport: OnyxEntry<Report>, actorAccountID: nu
iouReportUpdate.managerID = iouReport.ownerAccountID;
iouReportUpdate.total = -iouReportUpdate.total;
}

iouReportUpdate.hasOutstandingIOU = iouReportUpdate.total !== 0;
}

return iouReportUpdate;
Expand Down
2 changes: 0 additions & 2 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
searchText: null,
isDefaultRoom: false,
isPinned: false,
hasOutstandingIOU: false,
isWaitingOnBankAccount: false,
iouReportID: null,
isIOUReportOwner: null,
Expand Down Expand Up @@ -503,7 +502,6 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
result.iouReportID = report.iouReportID;
result.keyForList = String(report.reportID);
result.tooltipText = ReportUtils.getReportParticipantsTitle(report.participantAccountIDs || []);
result.hasOutstandingIOU = report.hasOutstandingIOU;
result.isWaitingOnBankAccount = report.isWaitingOnBankAccount;
result.policyID = report.policyID;

Expand Down
21 changes: 11 additions & 10 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ type OptimisticExpenseReport = Pick<
| 'policyID'
| 'type'
| 'ownerAccountID'
| 'hasOutstandingIOU'
| 'currency'
| 'reportName'
| 'state'
Expand Down Expand Up @@ -197,7 +196,6 @@ type OptimisticChatReport = Pick<
Report,
| 'type'
| 'chatType'
| 'hasOutstandingIOU'
| 'isOwnPolicyExpenseChat'
| 'isPinned'
| 'lastActorAccountID'
Expand Down Expand Up @@ -297,7 +295,6 @@ type TransactionDetails =
type OptimisticIOUReport = Pick<
Report,
| 'cachedTotal'
| 'hasOutstandingIOU'
| 'type'
| 'chatReportID'
| 'currency'
Expand Down Expand Up @@ -751,6 +748,13 @@ function isConciergeChatReport(report: OnyxEntry<Report>): boolean {
return report?.participantAccountIDs?.length === 1 && Number(report.participantAccountIDs?.[0]) === CONST.ACCOUNT_ID.CONCIERGE && !isChatThread(report);
}

/**
* Returns true if report is still being processed
*/
function isProcessingReport(report: OnyxEntry<Report>): boolean {
return report?.stateNum === CONST.REPORT.STATE_NUM.PROCESSING && report?.statusNum === CONST.REPORT.STATUS.SUBMITTED;
}

/**
* Check if the report is a single chat report that isn't a thread
* and personal detail of participant is optimistic data
Expand Down Expand Up @@ -1608,7 +1612,7 @@ function getMoneyRequestReimbursableTotal(report: OnyxEntry<Report>, allReportsD
if (isMoneyRequestReport(report)) {
moneyRequestReport = report;
}
if (allAvailableReports && report?.hasOutstandingIOU && report?.iouReportID) {
if (allAvailableReports && report?.iouReportID) {
moneyRequestReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`];
}
if (moneyRequestReport) {
Expand All @@ -1630,7 +1634,7 @@ function getMoneyRequestSpendBreakdown(report: OnyxEntry<Report>, allReportsDict
if (isMoneyRequestReport(report)) {
moneyRequestReport = report;
}
if (allAvailableReports && report?.hasOutstandingIOU && report?.iouReportID) {
if (allAvailableReports && report?.iouReportID) {
moneyRequestReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`];
}
if (moneyRequestReport) {
Expand Down Expand Up @@ -1724,7 +1728,7 @@ function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry<
return Localize.translateLocal('iou.payerSpentAmount', {payer: payerName, amount: formattedAmount});
}

if (!!report?.hasOutstandingIOU || isDraftExpenseReport(report) || moneyRequestTotal === 0) {
if (isProcessingReport(report) || isDraftExpenseReport(report) || moneyRequestTotal === 0) {
return Localize.translateLocal('iou.payerOwesAmount', {payer: payerName, amount: formattedAmount});
}

Expand Down Expand Up @@ -2549,8 +2553,6 @@ function buildOptimisticIOUReport(payeeAccountID: number, payerAccountID: number
const personalDetails = getPersonalDetailsForAccountID(payerAccountID);
const payerEmail = 'login' in personalDetails ? personalDetails.login : '';
return {
// If we're sending money, hasOutstandingIOU should be false
hasOutstandingIOU: !isSendingMoney,
type: CONST.REPORT.TYPE.IOU,
cachedTotal: formattedTotal,
chatReportID,
Expand Down Expand Up @@ -2604,7 +2606,6 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa
policyID,
type: CONST.REPORT.TYPE.EXPENSE,
ownerAccountID: payeeAccountID,
hasOutstandingIOU: true,
currency: outputCurrency,

// We don't translate reportName because the server response is always in English
Expand Down Expand Up @@ -3083,7 +3084,6 @@ function buildOptimisticChatReport(
return {
type: CONST.REPORT.TYPE.CHAT,
chatType,
hasOutstandingIOU: false,
isOwnPolicyExpenseChat,
isPinned: reportName === CONST.REPORT.WORKSPACE_CHAT_ROOMS.ADMINS || isNewlyCreatedWorkspaceChat,
lastActorAccountID: 0,
Expand Down Expand Up @@ -4342,6 +4342,7 @@ export {
isPublicRoom,
isPublicAnnounceRoom,
isConciergeChatReport,
isProcessingReport,
isCurrentUserTheOnlyParticipant,
hasAutomatedExpensifyAccountIDs,
hasExpensifyGuidesEmails,
Expand Down
Loading

0 comments on commit 86a2521

Please sign in to comment.