Skip to content

Commit

Permalink
Merge pull request #50762 from mkzie2/mkzie2-issue/49274
Browse files Browse the repository at this point in the history
fix: incorrect lhn report name when partially pay held report
  • Loading branch information
robertjchen authored Nov 4, 2024
2 parents 657531f + 8943a0f commit 4c04320
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ type OptimisticIOUReport = Pick<
| 'parentReportID'
| 'lastVisibleActionCreated'
| 'fieldList'
| 'parentReportActionID'
>;
type DisplayNameWithTooltips = Array<Pick<PersonalDetails, 'accountID' | 'pronouns' | 'displayName' | 'login' | 'avatar'>>;

Expand Down Expand Up @@ -4448,9 +4449,18 @@ function buildOptimisticTaskCommentReportAction(
* @param chatReportID - Report ID of the chat where the IOU is.
* @param currency - IOU currency.
* @param isSendingMoney - If we pay someone the IOU should be created as settled
* @param parentReportActionID - The parent report action ID of the IOU report
*/

function buildOptimisticIOUReport(payeeAccountID: number, payerAccountID: number, total: number, chatReportID: string, currency: string, isSendingMoney = false): OptimisticIOUReport {
function buildOptimisticIOUReport(
payeeAccountID: number,
payerAccountID: number,
total: number,
chatReportID: string,
currency: string,
isSendingMoney = false,
parentReportActionID?: string,
): OptimisticIOUReport {
const formattedTotal = CurrencyUtils.convertToDisplayString(total, currency);
const personalDetails = getPersonalDetailsForAccountID(payerAccountID);
const payerEmail = 'login' in personalDetails ? personalDetails.login : '';
Expand Down Expand Up @@ -4480,6 +4490,7 @@ function buildOptimisticIOUReport(payeeAccountID: number, payerAccountID: number
parentReportID: chatReportID,
lastVisibleActionCreated: DateUtils.getDBTime(),
fieldList: policy?.fieldList,
parentReportActionID,
};
}

Expand Down
10 changes: 9 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6571,7 +6571,15 @@ function getReportFromHoldRequestsOnyxData(
false,
newParentReportActionID,
)
: ReportUtils.buildOptimisticIOUReport(recipient.accountID ?? 1, iouReport?.managerID ?? 1, holdTransactionAmount, chatReport.reportID, getCurrency(firstHoldTransaction), false);
: ReportUtils.buildOptimisticIOUReport(
iouReport?.ownerAccountID ?? -1,
iouReport?.managerID ?? -1,
holdTransactionAmount,
chatReport.reportID,
getCurrency(firstHoldTransaction),
false,
newParentReportActionID,
);

const optimisticExpenseReportPreview = ReportUtils.buildOptimisticReportPreview(
chatReport,
Expand Down

0 comments on commit 4c04320

Please sign in to comment.