Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parentReportActionID to iouReport #44776

Merged
merged 7 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
actionName: CONST.REPORT.ACTIONS.TYPE.CREATED,
cretadn22 marked this conversation as resolved.
Show resolved Hide resolved
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;
cretadn22 marked this conversation as resolved.
Show resolved Hide resolved
cretadn22 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading