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
15 changes: 13 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10143,14 +10143,25 @@ function hasMissingPaymentMethod(userWalletTierName: string | undefined, iouRepo
* - we don't have an iouReport set in the chatReport
* - we have one, but it's waiting on the payee adding a bank account
* - we have one, but we can't add more transactions to it due to: report is approved or settled
* - It is a SmartScan request, the user is in the ASAP Submit beta, and the action is not "submit"
*/
function shouldCreateNewMoneyRequestReport(existingIOUReport: OnyxInputOrEntry<Report> | undefined, chatReport: OnyxInputOrEntry<Report>, isScanRequest: boolean): boolean {
function shouldCreateNewMoneyRequestReport(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a bullet to the comment above explaining why we don't create a new money request report for submit actions specifically?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@chuckdries I think it would be best to check with the internal team about the logic for when a new money request report should be created. Once we have clarity, we can document all the relevant cases directly in a comment on the shouldCreateNewMoneyRequestReport function—rather than only explaining why we don’t create a new report for submit actions specifically.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a little confused at what you mean. There already is a comment on shouldCreateNewMoneyRequestReport that explains when a new money request report should be created. I'm just saying it'd be helpful to add to it a note about why we're adding an exception for submit actions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@chuckdries I updated the comment to more clearly. Please help to check it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @thelullabyy, sorry to be so pedantic about this - I should've been more clear from the get-go. Can you please put in the comment why we're excluding submit actions specifically. Just briefly describe what the bug that we're solving is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@chuckdries In the comment I added to the function:

  • It is a SmartScan request, the user is in the ASAP Submit beta, and the action is not "submit"

I was simply highlighting that we create a new report only if the action is not "submit". However, as you pointed out, I wasn’t able to provide a clear explanation for why we don’t create a report when the action is "submit".

The reason I included the action !== CONST.IOU.ACTION.SUBMIT condition was purely to align with the current backend behavior.

If we need a definitive explanation for why a report isn't created in the "submit" case, we should probably reach out to the backend or internal team for clarification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Similar to the previous comment we added here:

* - we have one, but it's waiting on the payee adding a bank account

—it simply notes that when the it is waiting on the payee to add a bank account, we create a new report. However, it doesn't explain why that behavior is necessary in this case.

existingIOUReport: OnyxInputOrEntry<Report> | undefined,
chatReport: OnyxInputOrEntry<Report>,
isScanRequest: boolean,
action?: IOUAction,
): boolean {
if (existingIOUReport && !!existingIOUReport.errorFields?.createChat) {
return true;
}

const isASAPSubmitBetaEnabled = Permissions.isBetaEnabled(CONST.BETAS.ASAP_SUBMIT, allBetas);
return !existingIOUReport || hasIOUWaitingOnCurrentUserBankAccount(chatReport) || !canAddTransaction(existingIOUReport) || (isScanRequest && isASAPSubmitBetaEnabled);
return (
!existingIOUReport ||
hasIOUWaitingOnCurrentUserBankAccount(chatReport) ||
!canAddTransaction(existingIOUReport) ||
(action !== CONST.IOU.ACTION.SUBMIT && isScanRequest && isASAPSubmitBetaEnabled)
);
}

function getTripIDFromTransactionParentReportID(transactionParentReportID: string | undefined): string | undefined {
Expand Down
5 changes: 4 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ type MoneyRequestInformationParams = {
optimisticReportPreviewActionID?: string;
shouldGenerateTransactionThreadReport?: boolean;
isSplitExpense?: boolean;
action?: IOUAction;
};

type MoneyRequestOptimisticParams = {
Expand Down Expand Up @@ -3377,6 +3378,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
optimisticReportPreviewActionID,
shouldGenerateTransactionThreadReport = true,
isSplitExpense,
action,
} = moneyRequestInformation;
const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams;
const {policy, policyCategories, policyTagList} = policyParams;
Expand Down Expand Up @@ -3439,7 +3441,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
}

const isScanRequest = isScanRequestTransactionUtils({amount, receipt});
const shouldCreateNewMoneyRequestReport = isSplitExpense ? false : shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, isScanRequest);
const shouldCreateNewMoneyRequestReport = isSplitExpense ? false : shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, isScanRequest, action);

if (!iouReport || shouldCreateNewMoneyRequestReport) {
const nonReimbursableTotal = reimbursable ? 0 : amount;
Expand Down Expand Up @@ -5811,6 +5813,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) {
optimisticIOUReportID,
optimisticReportPreviewActionID,
shouldGenerateTransactionThreadReport,
action,
});
const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID;

Expand Down