-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: Set childReportID of the optimistic IOU report action #37232
Changes from 7 commits
0b6c83c
0d862fb
ab66870
1b8e9b5
47d6411
e894c66
1d286ae
fd7af59
0f96b28
72a6325
f57d723
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -926,7 +926,8 @@ function getMoneyRequestInformation( | |
false, | ||
currentTime, | ||
); | ||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(iouAction, iouReport.reportID); | ||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(iouAction, iouReport); | ||
iouAction.childReportID = optimisticTransactionThread.reportID; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a comment above this line saying why we need to do this? It's not super obvious right away, and it made me wonder if we should be setting this in I don't have a good solution for that right now -- it seems like we could generate an optimistic reportID before the calls to I'm curious what you think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, unfortunately these 2 are co-dependent: the transaction thread has the iou action's ID as the parent action ID, and vice versa. Also, passing the pre-generated report ID will cause a lot of refactoring of the current methods that use the Smth like: function buildOptimisticIOUReportActionWithTransactionThread(...) {
const iouAction = ReportUtils.buildOptimisticIOUReportAction(
CONST.IOU.REPORT_ACTION_TYPE.CREATE,
amount,
currency,
comment,
[participant],
optimisticTransaction.transactionID,
undefined,
iouReport.reportID,
false,
false,
receiptObject,
false,
currentTime,
);
const optimisticTransactionThread = ReportUtils.buildTransactionThread(iouAction, iouReport.reportID);
iouAction.childReportID = optimisticTransactionThread.reportID;
const optimisticCreatedActionForTransactionThread = ReportUtils.buildOptimisticCreatedReportAction(payeeEmail);
return { iouAction, optimisticTransactionThread, optimisticCreatedActionForTransactionThread }
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I thought of that but wasn't convinced it would be better. But on second thought, I do think it's better and we can add a comment inside that function above where we set The alternative would be to put that comment in 4 places, and we'd have that code duplicated like you said, and nothing prevents people from forgetting to set I'm good to update to this 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done ✔️ @situchan I've re-tested the 4 different flows that use the 4 different functions that call this new
|
||
const optimisticCreatedActionForTransactionThread = ReportUtils.buildOptimisticCreatedReportAction(payeeEmail); | ||
|
||
let reportPreviewAction = shouldCreateNewMoneyRequestReport ? null : ReportActionsUtils.getReportPreviewAction(chatReport.reportID, iouReport.reportID); | ||
|
@@ -1933,7 +1934,8 @@ function createSplitsAndOnyxData( | |
const optimisticPolicyRecentlyUsedTags = isPolicyExpenseChat ? Policy.buildOptimisticPolicyRecentlyUsedTags(participant.policyID, tag) : {}; | ||
|
||
// Create optimistic transactionThread | ||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(oneOnOneIOUAction, oneOnOneIOUReport.reportID); | ||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(oneOnOneIOUAction, oneOnOneIOUReport); | ||
oneOnOneIOUAction.childReportID = optimisticTransactionThread.reportID; | ||
const optimisticCreatedActionForTransactionThread = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmailForIOUSplit); | ||
|
||
// STEP 5: Build Onyx Data | ||
|
@@ -2052,7 +2054,7 @@ function splitBill( | |
} | ||
|
||
/** | ||
* @param amount - always in smallest currency unit | ||
* @param amount - always in the smallest currency unit | ||
*/ | ||
function splitBillAndOpenReport( | ||
participants: Participant[], | ||
|
@@ -2537,7 +2539,8 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA | |
oneOnOneReportPreviewAction = ReportUtils.buildOptimisticReportPreview(oneOnOneChatReport, oneOnOneIOUReport, '', oneOnOneTransaction); | ||
} | ||
|
||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(oneOnOneIOUAction, oneOnOneIOUReport.reportID); | ||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(oneOnOneIOUAction, oneOnOneIOUReport); | ||
oneOnOneIOUAction.childReportID = optimisticTransactionThread.reportID; | ||
const optimisticCreatedActionForTransactionThread = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmailForIOUSplit); | ||
|
||
const [oneOnOneOptimisticData, oneOnOneSuccessData, oneOnOneFailureData] = buildOnyxDataForMoneyRequest( | ||
|
@@ -3264,7 +3267,8 @@ function getSendMoneyParams( | |
|
||
const reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, optimisticIOUReport); | ||
|
||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(optimisticIOUReportAction, optimisticIOUReport.reportID); | ||
const optimisticTransactionThread = ReportUtils.buildTransactionThread(optimisticIOUReportAction, optimisticIOUReport); | ||
optimisticIOUReportAction.childReportID = optimisticTransactionThread.reportID; | ||
const optimisticCreatedActionForTransactionThread = ReportUtils.buildOptimisticCreatedReportAction(recipientEmail); | ||
|
||
// Change the method to set for new reports because it doesn't exist yet, is faster, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we removing this because we're always creating transaction threads in the backend, and
action?.childReportID
will be set to the ID of that transaction thread?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We've discussed it briefly here: #37232 (comment)