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

Remove unneeded condition for Send Money/Request distance #40096

Merged
merged 7 commits into from
Apr 11, 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
6 changes: 3 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@

/** Requests money based on a distance (e.g. mileage from a map) */
function createDistanceRequest(
report: OnyxTypes.Report,
report: OnyxEntry<OnyxTypes.Report>,
participant: Participant,
comment: string,
created: string,
Expand All @@ -1508,8 +1508,8 @@
) {
// If the report is an iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function
const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report;

Check failure on line 1511 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / typecheck

'report' is possibly 'null'.
const moneyRequestReportID = isMoneyRequestReport ? report.reportID : '';

Check failure on line 1512 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / typecheck

'report' is possibly 'null'.
const currentCreated = DateUtils.enrichMoneyRequestTimestamp(created);

const optimisticReceipt: Receipt = {
Expand Down Expand Up @@ -1569,7 +1569,7 @@
};

API.write(WRITE_COMMANDS.CREATE_DISTANCE_REQUEST, parameters, onyxData);
Navigation.dismissModal(isMoneyRequestReport ? report.reportID : chatReport.reportID);

Check failure on line 1572 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / typecheck

'report' is possibly 'null'.
Report.notifyNewAction(chatReport.reportID, userAccountID);
}

Expand Down Expand Up @@ -4768,8 +4768,8 @@
* @param managerID - Account ID of the person sending the money
* @param recipient - The user receiving the money
*/
function sendMoneyElsewhere(report: OnyxTypes.Report, amount: number, currency: string, comment: string, managerID: number, recipient: Participant) {
function sendMoneyElsewhere(report: OnyxEntry<OnyxTypes.Report>, amount: number, currency: string, comment: string, managerID: number, recipient: Participant) {
const {params, optimisticData, successData, failureData} = getSendMoneyParams(report, amount, currency, comment, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, managerID, recipient);

Check failure on line 4772 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'OnyxEntry<{ avatarUrl?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly GROUP: "group"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "sel...' is not assignable to parameter of type '{ avatarUrl?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly GROUP: "group"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> |...'.

API.write(WRITE_COMMANDS.SEND_MONEY_ELSEWHERE, params, {optimisticData, successData, failureData});

Expand All @@ -4782,8 +4782,8 @@
* @param managerID - Account ID of the person sending the money
* @param recipient - The user receiving the money
*/
function sendMoneyWithWallet(report: OnyxTypes.Report, amount: number, currency: string, comment: string, managerID: number, recipient: Participant | ReportUtils.OptionData) {
function sendMoneyWithWallet(report: OnyxEntry<OnyxTypes.Report>, amount: number, currency: string, comment: string, managerID: number, recipient: Participant | ReportUtils.OptionData) {
const {params, optimisticData, successData, failureData} = getSendMoneyParams(report, amount, currency, comment, CONST.IOU.PAYMENT_TYPE.EXPENSIFY, managerID, recipient);

Check failure on line 4786 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'OnyxEntry<{ avatarUrl?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly GROUP: "group"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "sel...' is not assignable to parameter of type '{ avatarUrl?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly GROUP: "group"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> |...'.

API.write(WRITE_COMMANDS.SEND_MONEY_WITH_WALLET, params, {optimisticData, successData, failureData});

Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function IOURequestStepConfirmation({

const createDistanceRequest = useCallback(
(selectedParticipants: Participant[], trimmedComment: string) => {
if (!report || !transaction) {
if (!transaction) {
return;
}
IOU.createDistanceRequest(
Expand Down Expand Up @@ -433,7 +433,7 @@ function IOURequestStepConfirmation({

const participant = participants?.[0];

if (!participant || !report || !transaction?.amount || !currency) {
if (!participant || !transaction?.amount || !currency) {
return;
}

Expand Down
Loading