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

Ensure isOptimisticReport is set and fix issues with optimistic reports getting deleted on reconnect #36538

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ type OptimisticChatReport = Pick<
| 'visibility'
| 'description'
| 'writeCapability'
>;
> & {
isOptimisticReport: true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isOptimisticReport was already defined in Report.ts
Any reason for adding here instead of picking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is an optional bool in the base Report type. This forces OptimisticChatReport to always have it set to true.

};

type OptimisticTaskReportAction = Pick<
ReportAction,
Expand Down Expand Up @@ -3324,6 +3326,7 @@ function buildOptimisticChatReport(
const currentTime = DateUtils.getDBTime();
const isNewlyCreatedWorkspaceChat = chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT && isOwnPolicyExpenseChat;
return {
isOptimisticReport: true,
type: CONST.REPORT.TYPE.CHAT,
chatType,
isOwnPolicyExpenseChat,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ function createSplitsAndOnyxData(

// STEP 1: Get existing chat report OR build a new optimistic one
// If we only have one participant and the request was initiated from the global create menu, i.e. !existingGroupChatReportID, the oneOnOneChatReport is the groupChatReport
let oneOnOneChatReport: OptimisticChatReport;
let oneOnOneChatReport: OnyxTypes.Report | OptimisticChatReport;
let isNewOneOnOneChatReport = false;
let shouldCreateOptimisticPersonalDetails = false;
const personalDetailExists = accountID in allPersonalDetails;
Expand Down
Loading