Skip to content
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: 5 additions & 0 deletions src/libs/actions/IOU/SendInvoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type SendInvoiceOptions = {
currentUserAccountID: number;
policyRecentlyUsedCurrencies: string[];
invoiceChatReport?: OnyxEntry<OnyxTypes.Report>;
invoiceChatReportID?: string;
receiptFile?: Receipt;
policy?: OnyxEntry<OnyxTypes.Policy>;
policyTagList?: OnyxEntry<OnyxTypes.PolicyTagLists>;
Expand Down Expand Up @@ -522,6 +523,7 @@ function getSendInvoiceInformation({
currentUserAccountID,
policyRecentlyUsedCurrencies,
invoiceChatReport,
invoiceChatReportID,
receiptFile,
policy,
policyTagList,
Expand All @@ -548,6 +550,7 @@ function getSendInvoiceInformation({
if (!chatReport) {
isNewChatReport = true;
chatReport = buildOptimisticChatReport({
optimisticReportID: invoiceChatReportID,
participantList: [receiverAccountID, currentUserAccountID],
chatType: CONST.REPORT.CHAT_TYPE.INVOICE,
policyID: senderWorkspaceID,
Expand Down Expand Up @@ -671,6 +674,7 @@ function sendInvoice({
policy,
policyTagList,
policyCategories,
invoiceChatReportID,
companyName,
companyWebsite,
policyRecentlyUsedCategories,
Expand Down Expand Up @@ -698,6 +702,7 @@ function sendInvoice({
transaction,
currentUserAccountID,
policyRecentlyUsedCurrencies,
invoiceChatReportID,
invoiceChatReport,
receiptFile,
policy,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -995,12 +995,14 @@ function IOURequestStepConfirmation({
if (iouType === CONST.IOU.TYPE.INVOICE) {
const invoiceChatReport =
!isEmptyObject(report) && report?.reportID && doesReportReceiverMatchParticipant(report, receiverParticipantAccountID) ? report : existingInvoiceReport;
const invoiceChatReportID = invoiceChatReport ? undefined : reportID;

sendInvoice({
currentUserAccountID: currentUserPersonalDetails.accountID,
transaction,
policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [],
invoiceChatReport,
invoiceChatReportID,
receiptFile: currentTransactionReceiptFile,
policy,
policyTagList: policyTags,
Expand Down Expand Up @@ -1124,6 +1126,7 @@ function IOURequestStepConfirmation({
userLocation,
submitPerDiemExpense,
policyRecentlyUsedCurrencies,
reportID,
],
);

Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/request/step/IOURequestStepParticipants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function IOURequestStepParticipants({
const firstParticipantReportID = val.at(0)?.reportID;
const isPolicyExpenseChat = !!firstParticipant?.isPolicyExpenseChat;
const policy = isPolicyExpenseChat && firstParticipant?.policyID ? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${firstParticipant.policyID}`] : undefined;
const isInvoice = iouType === CONST.IOU.TYPE.INVOICE && isInvoiceRoomWithID(firstParticipantReportID);
const isInvoice = iouType === CONST.IOU.TYPE.INVOICE && firstParticipant?.iouType === CONST.IOU.TYPE.INVOICE;
numberOfParticipants.current = val.length;

// Use transactions array if available, otherwise use initialTransactionID directly
Expand Down Expand Up @@ -285,7 +285,7 @@ function IOURequestStepParticipants({
// When a participant is selected, the reportID needs to be saved because that's the reportID that will be used in the confirmation step.
// We use || to be sure that if the first participant doesn't have a reportID, we generate a new one.
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
selectedReportID.current = firstParticipantReportID || generateReportID();
selectedReportID.current = firstParticipantReportID && isInvoiceRoomWithID(firstParticipantReportID) ? firstParticipantReportID : generateReportID();

// IOUs are always reported. non-CREATE actions require a report
if (!isPolicyExpenseChat || action !== CONST.IOU.ACTION.CREATE) {
Expand Down
Loading