Skip to content

Commit

Permalink
Merge pull request #46166 from tsa321/fixLhnDisplaysOwes000
Browse files Browse the repository at this point in the history
Fix LHN displays "...owes 0.00" when user receives split request message
  • Loading branch information
neil-marcellini authored Jul 26, 2024
2 parents 67a3378 + 1c26ea4 commit 7e3c84d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as DraftCommentUtils from '@libs/DraftCommentUtils';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -118,6 +119,10 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
const itemReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`];
const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`];
const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? '-1'];

const iouReportIDOfLastAction = OptionsListUtils.getIOUReportIDOfLastAction(itemFullReport);
const itemIouReportReportActions = iouReportIDOfLastAction ? reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportIDOfLastAction}`] : undefined;

const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`];
const transactionID = ReportActionsUtils.isMoneyRequestAction(itemParentReportAction)
? ReportActionsUtils.getOriginalMessage(itemParentReportAction)?.IOUTransactionID ?? '-1'
Expand All @@ -141,6 +146,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
fullReport={itemFullReport}
reportActions={itemReportActions}
parentReportAction={itemParentReportAction}
iouReportReportActions={itemIouReportReportActions}
policy={itemPolicy}
personalDetails={personalDetails ?? {}}
transaction={itemTransaction}
Expand Down
2 changes: 2 additions & 0 deletions src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function OptionRowLHNData({
policy,
receiptTransactions,
parentReportAction,
iouReportReportActions,
transaction,
lastReportActionTransaction,
transactionViolations,
Expand Down Expand Up @@ -68,6 +69,7 @@ function OptionRowLHNData({
preferredLocale,
policy,
parentReportAction,
iouReportReportActions,
transaction,
transactionViolations,
canUseViolations,
Expand Down
3 changes: 3 additions & 0 deletions src/components/LHNOptionsList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ type OptionRowLHNDataProps = {
/** Array of report actions for this report */
reportActions: OnyxEntry<ReportActions>;

/** Array of report actions of IOU report related to this report last action */
iouReportReportActions: OnyxEntry<ReportActions>;

/** List of transaction violation */
transactionViolations: OnyxCollection<TransactionViolation[]>;

Expand Down
15 changes: 15 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,20 @@ function isSearchStringMatchUserDetails(personalDetail: PersonalDetails, searchV
return isSearchStringMatch(searchValue.trim(), memberDetails.toLowerCase());
}

/**
* Get IOU report ID of report last action if the action is report action preview
*/
function getIOUReportIDOfLastAction(report: OnyxEntry<Report>): string | undefined {
if (!report?.reportID) {
return;
}
const lastAction = visibleReportActionItems[report.reportID];
if (!ReportActionUtils.isReportPreviewAction(lastAction)) {
return;
}
return getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastAction))?.reportID;
}

/**
* Get the last message text from the report directly or from other sources for special cases.
*/
Expand Down Expand Up @@ -2634,6 +2648,7 @@ export {
isSearchStringMatchUserDetails,
getAllReportErrors,
getPolicyExpenseReportOption,
getIOUReportIDOfLastAction,
getParticipantsOption,
isSearchStringMatch,
shouldOptionShowTooltip,
Expand Down

0 comments on commit 7e3c84d

Please sign in to comment.