Skip to content

Commit

Permalink
add parentReportActionID to iouReport
Browse files Browse the repository at this point in the history
  • Loading branch information
cretadn22 committed Jul 3, 2024
1 parent ccb5b5a commit 60c39db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ type OptimisticExpenseReport = Pick<
| 'notificationPreference'
| 'parentReportID'
| 'lastVisibleActionCreated'
| 'parentReportActionID'
>;

type OptimisticIOUReportAction = Pick<
Expand Down Expand Up @@ -4721,9 +4722,9 @@ function buildOptimisticGroupChatReport(
* Returns the necessary reportAction onyx data to indicate that the chat has been created optimistically
* @param [created] - Action created time
*/
function buildOptimisticCreatedReportAction(emailCreatingAction: string, created = DateUtils.getDBTime()): OptimisticCreatedReportAction {
function buildOptimisticCreatedReportAction(emailCreatingAction: string, created = DateUtils.getDBTime(), reportActionID?: string): OptimisticCreatedReportAction {
return {
reportActionID: NumberUtils.rand64(),
reportActionID: reportActionID || NumberUtils.rand64(),

Check failure on line 4727 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator
actionName: CONST.REPORT.ACTIONS.TYPE.CREATED,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
actorAccountID: currentUserAccountID,
Expand Down Expand Up @@ -5236,7 +5237,7 @@ function buildOptimisticMoneyRequestEntities(
existingTransactionThreadReportID?: string,
linkedTrackedExpenseReportAction?: ReportAction,
): [OptimisticCreatedReportAction, OptimisticCreatedReportAction, OptimisticIOUReportAction, OptimisticChatReport, OptimisticCreatedReportAction | null] {
const createdActionForChat = buildOptimisticCreatedReportAction(payeeEmail);
const createdActionForChat = buildOptimisticCreatedReportAction(payeeEmail, undefined, iouReport.parentReportActionID);

// The `CREATED` action must be optimistically generated before the IOU action so that it won't appear after the IOU action in the chat.
const iouActionCreationTime = DateUtils.getDBTime();
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,8 @@ function getSendInvoiceInformation(
}

// STEP 5: Build optimistic reportActions.
const reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, optimisticInvoiceReport, trimmedComment, optimisticTransaction);
optimisticInvoiceReport.parentReportActionID = reportPreviewAction.reportActionID;
const [optimisticCreatedActionForChat, optimisticCreatedActionForIOUReport, iouAction, optimisticTransactionThread, optimisticCreatedActionForTransactionThread] =
ReportUtils.buildOptimisticMoneyRequestEntities(
optimisticInvoiceReport,
Expand All @@ -1848,7 +1850,6 @@ function getSendInvoiceInformation(
receiptObject,
false,
);
const reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, optimisticInvoiceReport, trimmedComment, optimisticTransaction);

// STEP 6: Build Onyx Data
const [optimisticData, successData, failureData] = buildOnyxDataForInvoice(
Expand Down

0 comments on commit 60c39db

Please sign in to comment.