Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2cd62ce
chore: test commit for the linter
adhorodyski Dec 18, 2024
2f53a1a
chore: fix lint errors on missing CONST.DEFAULT_NUMBER_ID usages for …
adhorodyski Dec 18, 2024
9f0352f
chore: rm a dummy console log
adhorodyski Dec 18, 2024
dd0de46
chore: remove an eslint override for the IOU.ts file exclusion
adhorodyski Dec 18, 2024
661790f
chore: add an early return for transactionThreadReportIDs of undefined
adhorodyski Dec 18, 2024
1ddfa90
chore: add an early return on invalid input to the payInvoice function
adhorodyski Dec 18, 2024
529b1f6
chore: filter out undefiend values
adhorodyski Dec 19, 2024
17829b7
chore: allow undefined output from getIOURequestPolicyID
adhorodyski Dec 19, 2024
cf617bd
chore: remove a fallback index access on the failure data
adhorodyski Dec 19, 2024
1b42796
chore: early return on missing input to the cancelPayment func
adhorodyski Dec 19, 2024
2042569
chore: remove more onyx key fallbacks
adhorodyski Dec 19, 2024
c98da87
Merge branch 'Expensify:main' into chore/eslint-consistent-id-iou
adhorodyski Dec 19, 2024
d268002
chore: optionally push to the optimistic data
adhorodyski Dec 19, 2024
93d2cbd
chore: wrap a success data push in an if statement for undefined input
adhorodyski Dec 19, 2024
2c83daa
chore: wrap a failure data push in an if statement for undefined input
adhorodyski Dec 19, 2024
135baa7
chore: wrap L1831 failure data push
adhorodyski Dec 19, 2024
0ab1de1
chore: early return on missing splitData.createdReportActionID for th…
adhorodyski Dec 19, 2024
46e8c8e
chore: pass in undefined with a missing childReportID
adhorodyski Dec 19, 2024
390df26
chore: extract an optimisticData push to ensure a param
adhorodyski Dec 19, 2024
cdccb13
chore: use string or undefined as a value
adhorodyski Dec 19, 2024
de2c69b
chore: call 2 new optimistic updates only on conditions met
adhorodyski Dec 19, 2024
2ece26c
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Dec 20, 2024
2332beb
Update getLastVisibleAction and getLastVisibleMessage functions. Remo…
VickyStash Dec 20, 2024
871a257
Remove '-1' id from object keys
VickyStash Dec 20, 2024
80901b5
Fix test
VickyStash Dec 20, 2024
617f8b0
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Dec 24, 2024
0caab12
Fix params related lint errors
VickyStash Dec 24, 2024
ac221d1
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Dec 30, 2024
bf73430
Lint fix
VickyStash Dec 30, 2024
a0905d6
Code polish
VickyStash Dec 30, 2024
4a7725c
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Jan 2, 2025
3980ff6
Minor updates after merging main
VickyStash Jan 2, 2025
6c6026c
Remove null value merging
VickyStash Jan 2, 2025
435df71
Minor improvement
VickyStash Jan 2, 2025
64a3bb9
Fix reportPreviewAction type
VickyStash Jan 2, 2025
a870404
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Jan 2, 2025
f6e9122
Update Transaction type
VickyStash Jan 2, 2025
eebf2ed
Lint fix
VickyStash Jan 2, 2025
de9d29a
Apply reviewer feedback
VickyStash Jan 3, 2025
5c94b53
Add earlier return
VickyStash Jan 3, 2025
1944093
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Jan 8, 2025
3928260
Add warn logs to invalid routes
VickyStash Jan 8, 2025
ddd4709
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Jan 13, 2025
2d2c24f
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Jan 16, 2025
8b015b9
TS fix
VickyStash Jan 16, 2025
d23067e
Lint fixes
VickyStash Jan 16, 2025
8ddbf17
Minor lint fix
VickyStash Jan 16, 2025
7471970
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Jan 20, 2025
7d8cc98
Apply reviewer feedback, fix errors after merging main
VickyStash Jan 20, 2025
1dbedd9
Minor code improvements
VickyStash Jan 20, 2025
a91d701
Don't merge empty object to onyx
VickyStash Jan 20, 2025
afaa92e
Merge branch 'refs/heads/main' into chore/eslint-consistent-id-iou
VickyStash Jan 21, 2025
4d75438
Fix lint errors
VickyStash Jan 21, 2025
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
2 changes: 1 addition & 1 deletion .eslintrc.changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
},
overrides: [
{
files: ['src/libs/actions/IOU.ts', 'src/pages/workspace/WorkspaceInitialPage.tsx', 'src/pages/home/report/PureReportActionItem.tsx', 'src/libs/SidebarUtils.ts'],
files: ['src/pages/workspace/WorkspaceInitialPage.tsx', 'src/pages/home/report/PureReportActionItem.tsx', 'src/libs/SidebarUtils.ts'],
rules: {
'rulesdir/no-default-id-values': 'off',
},
Expand Down
12 changes: 10 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,10 @@ const ROUTES = {
},
ROOM_INVITE: {
route: 'r/:reportID/invite/:role?',
getRoute: (reportID: string, role?: string, backTo?: string) => {
getRoute: (reportID: string | undefined, role?: string, backTo?: string) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the ROOM_INVITE route');
}
const route = role ? (`r/${reportID}/invite/${role}` as const) : (`r/${reportID}/invite` as const);
return getUrlWithBackToParam(route, backTo);
},
Expand Down Expand Up @@ -770,7 +773,12 @@ const ROUTES = {
},
WORKSPACE_PROFILE_ADDRESS: {
route: 'settings/workspaces/:policyID/profile/address',
getRoute: (policyID: string, backTo?: string) => getUrlWithBackToParam(`settings/workspaces/${policyID}/profile/address` as const, backTo),
getRoute: (policyID: string | undefined, backTo?: string) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the WORKSPACE_PROFILE_ADDRESS route');
}
return getUrlWithBackToParam(`settings/workspaces/${policyID}/profile/address` as const, backTo);
},
},
WORKSPACE_PROFILE_PLAN: {
route: 'settings/workspaces/:policyID/profile/plan',
Expand Down
12 changes: 6 additions & 6 deletions src/libs/API/parameters/CategorizeTrackedExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ type CategorizeTrackedExpenseParams = {
comment: string;
created: string;
merchant: string;
policyID: string;
transactionID: string;
moneyRequestPreviewReportActionID: string;
moneyRequestReportID: string;
moneyRequestCreatedReportActionID: string;
policyID: string | undefined;
transactionID: string | undefined;
moneyRequestPreviewReportActionID: string | undefined;
moneyRequestReportID: string | undefined;
moneyRequestCreatedReportActionID: string | undefined;
actionableWhisperReportActionID: string;
modifiedExpenseReportActionID: string;
reportPreviewReportActionID: string;
reportPreviewReportActionID: string | undefined;
category?: string;
tag?: string;
receipt?: Receipt;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/API/parameters/CompleteSplitBillParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type CompleteSplitBillParams = {
transactionID: string;
transactionID: string | undefined;
amount?: number;
currency?: string;
created?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ type ConvertTrackedExpenseToRequestParams = {
chatReportID: string;
transactionID: string;
actionableWhisperReportActionID: string;
createdChatReportActionID: string;
createdChatReportActionID?: string;
moneyRequestReportID: string;
moneyRequestCreatedReportActionID: string;
moneyRequestCreatedReportActionID: string | undefined;
moneyRequestPreviewReportActionID: string;
reportPreviewReportActionID: string;
};
Expand Down
2 changes: 1 addition & 1 deletion src/libs/API/parameters/CreateDistanceRequestParams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type CreateDistanceRequestParams = {
transactionID: string;
chatReportID: string;
createdChatReportActionID: string;
createdChatReportActionID?: string;
reportActionID: string;
waypoints: string;
customUnitRateID: string;
Expand Down
6 changes: 3 additions & 3 deletions src/libs/API/parameters/CreatePerDiemRequestParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type CreatePerDiemRequestParams = {
chatReportID: string;
transactionID: string;
reportActionID: string;
createdChatReportActionID: string;
createdIOUReportActionID: string;
createdChatReportActionID?: string;
createdIOUReportActionID?: string;
reportPreviewReportActionID: string;
transactionThreadReportID: string;
createdReportActionIDForThread: string;
createdReportActionIDForThread: string | undefined;
};

export default CreatePerDiemRequestParams;
2 changes: 1 addition & 1 deletion src/libs/API/parameters/DeleteMoneyRequestParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type DeleteMoneyRequestParams = {
transactionID: string;
transactionID: string | undefined;
reportActionID: string;
};

Expand Down
2 changes: 1 addition & 1 deletion src/libs/API/parameters/PayInvoiceParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import type CreateWorkspaceParams from './CreateWorkspaceParams';

type PayInvoiceParams = Partial<CreateWorkspaceParams> & {
reportID: string;
reportID: string | undefined;
reportActionID: string;
paymentMethodType: PaymentMethodType;
payAsBusiness: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/API/parameters/PayMoneyRequestParams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';

type PayMoneyRequestParams = {
iouReportID: string;
iouReportID: string | undefined;
chatReportID: string;
reportActionID: string;
paymentMethodType: PaymentMethodType;
Expand Down
6 changes: 3 additions & 3 deletions src/libs/API/parameters/RequestMoneyParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type RequestMoneyParams = {
chatReportID: string;
transactionID: string;
reportActionID: string;
createdChatReportActionID: string;
createdIOUReportActionID: string;
createdChatReportActionID?: string;
createdIOUReportActionID?: string;
reportPreviewReportActionID: string;
receipt?: Receipt;
receiptState?: ValueOf<typeof CONST.IOU.RECEIPT_STATE>;
Expand All @@ -26,7 +26,7 @@ type RequestMoneyParams = {
billable?: boolean;
receiptGpsPoints?: string;
transactionThreadReportID: string;
createdReportActionIDForThread: string;
createdReportActionIDForThread: string | undefined;
reimbursible?: boolean;
};

Expand Down
4 changes: 2 additions & 2 deletions src/libs/API/parameters/SendInvoiceParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {RequireAtLeastOne} from 'type-fest';

type SendInvoiceParams = RequireAtLeastOne<
{
senderWorkspaceID: string;
senderWorkspaceID: string | undefined;
accountID: number;
receiverEmail?: string;
receiverInvoiceRoomID?: string;
Expand All @@ -21,7 +21,7 @@ type SendInvoiceParams = RequireAtLeastOne<
companyName?: string;
companyWebsite?: string;
createdIOUReportActionID: string;
createdReportActionIDForThread: string;
createdReportActionIDForThread: string | undefined;
reportActionID: string;
},
'receiverEmail' | 'receiverInvoiceRoomID'
Expand Down
4 changes: 2 additions & 2 deletions src/libs/API/parameters/SendMoneyParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ type SendMoneyParams = {
paymentMethodType: PaymentMethodType;
transactionID: string;
newIOUReportDetails: string;
createdReportActionID: string;
createdReportActionID: string | undefined;
reportPreviewReportActionID: string;
createdIOUReportActionID: string;
transactionThreadReportID: string;
createdReportActionIDForThread: string;
createdReportActionIDForThread: string | undefined;
};

export default SendMoneyParams;
12 changes: 6 additions & 6 deletions src/libs/API/parameters/ShareTrackedExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ type ShareTrackedExpenseParams = {
comment: string;
created: string;
merchant: string;
policyID: string;
transactionID: string;
moneyRequestPreviewReportActionID: string;
moneyRequestReportID: string;
moneyRequestCreatedReportActionID: string;
policyID: string | undefined;
transactionID: string | undefined;
moneyRequestPreviewReportActionID: string | undefined;
moneyRequestReportID: string | undefined;
moneyRequestCreatedReportActionID: string | undefined;
actionableWhisperReportActionID: string;
modifiedExpenseReportActionID: string;
reportPreviewReportActionID: string;
reportPreviewReportActionID: string | undefined;
category?: string;
tag?: string;
receipt?: Receipt;
Expand Down
12 changes: 6 additions & 6 deletions src/libs/API/parameters/TrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ type TrackExpenseParams = {
created: string;
merchant: string;
iouReportID?: string;
chatReportID: string;
transactionID: string;
reportActionID: string;
createdChatReportActionID: string;
chatReportID: string | undefined;
transactionID: string | undefined;
reportActionID: string | undefined;
createdChatReportActionID?: string;
createdIOUReportActionID?: string;
reportPreviewReportActionID?: string;
receipt?: Receipt;
Expand All @@ -23,8 +23,8 @@ type TrackExpenseParams = {
taxAmount: number;
billable?: boolean;
receiptGpsPoints?: string;
transactionThreadReportID: string;
createdReportActionIDForThread: string;
transactionThreadReportID: string | undefined;
createdReportActionIDForThread: string | undefined;
waypoints?: string;
actionableWhisperReportActionID?: string;
customUnitRateID?: string;
Expand Down
5 changes: 4 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,10 @@ function wasActionTakenByCurrentUser(reportAction: OnyxInputOrEntry<ReportAction
/**
* Get IOU action for a reportID and transactionID
*/
function getIOUActionForReportID(reportID: string, transactionID: string): OnyxEntry<ReportAction> {
function getIOUActionForReportID(reportID: string | undefined, transactionID: string): OnyxEntry<ReportAction> {
if (!reportID) {
return;
}
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const reportActions = getAllReportActions(report?.reportID);
const action = Object.values(reportActions ?? {})?.find((reportAction) => {
Expand Down
28 changes: 17 additions & 11 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ Onyx.connect({

reportsTransactions = Object.values(value).reduce<Record<string, Transaction[]>>((all, transaction) => {
const reportsMap = all;
if (!transaction) {
if (!transaction?.reportID) {
return reportsMap;
}

Expand Down Expand Up @@ -3191,6 +3191,10 @@ function getReportFieldKey(reportFieldId: string | undefined) {
* Get the report fields attached to the policy given policyID
*/
function getReportFieldsByPolicyID(policyID: string | undefined): Record<string, PolicyReportField> {
if (!policyID) {
return {};
}

const policyReportFields = Object.entries(allPolicies ?? {}).find(([key]) => key.replace(ONYXKEYS.COLLECTION.POLICY, '') === policyID);
const fieldList = policyReportFields?.[1]?.fieldList;

Expand Down Expand Up @@ -4801,7 +4805,7 @@ function buildOptimisticIOUReport(
payeeAccountID: number,
payerAccountID: number,
total: number,
chatReportID: string,
chatReportID: string | undefined,
currency: string,
isSendingMoney = false,
parentReportActionID?: string,
Expand Down Expand Up @@ -4873,7 +4877,14 @@ function populateOptimisticReportFormula(formula: string, report: OptimisticExpe
}

/** Builds an optimistic invoice report with a randomly generated reportID */
function buildOptimisticInvoiceReport(chatReportID: string, policyID: string, receiverAccountID: number, receiverName: string, total: number, currency: string): OptimisticExpenseReport {
function buildOptimisticInvoiceReport(
chatReportID: string,
policyID: string | undefined,
Comment thread
neil-marcellini marked this conversation as resolved.
receiverAccountID: number,
receiverName: string,
total: number,
currency: string,
): OptimisticExpenseReport {
const formattedTotal = convertToDisplayString(total, currency);
const invoiceReport = {
reportID: generateReportID(),
Expand Down Expand Up @@ -4945,8 +4956,8 @@ function getExpenseReportStateAndStatus(policy: OnyxEntry<Policy>) {
* @param parentReportActionID – The parent ReportActionID of the PolicyExpenseChat
*/
function buildOptimisticExpenseReport(
chatReportID: string,
policyID: string,
chatReportID: string | undefined,
policyID: string | undefined,
payeeAccountID: number,
total: number,
currency: string,
Expand Down Expand Up @@ -5547,7 +5558,7 @@ function buildOptimisticModifiedExpenseReportAction(
* @param transactionThreadID - The reportID of the transaction thread
* @param movedToReportID - The reportID of the report the transaction is moved to
*/
function buildOptimisticMovedTrackedExpenseModifiedReportAction(transactionThreadID: string, movedToReportID: string): OptimisticModifiedExpenseReportAction {
function buildOptimisticMovedTrackedExpenseModifiedReportAction(transactionThreadID: string | undefined, movedToReportID: string | undefined): OptimisticModifiedExpenseReportAction {
const delegateAccountDetails = getPersonalDetailByEmail(delegateEmail);

return {
Expand Down Expand Up @@ -8581,10 +8592,6 @@ function canReportBeMentionedWithinPolicy(report: OnyxEntry<Report>, policyID: s
return isChatRoom(report) && !isInvoiceRoom(report) && !isThread(report);
}

function shouldShowMerchantColumn(transactions: Transaction[]) {
return transactions.some((transaction) => isExpenseReport(allReports?.[transaction.reportID] ?? null));
}

/**
* Whether a given report is used for onboarding tasks. In the past, it could be either the Concierge chat or the system
* DM, and we saved the report ID in the user's `onboarding` NVP. As a fallback for users who don't have the NVP, we now
Expand Down Expand Up @@ -9123,7 +9130,6 @@ export {
getTripIDFromTransactionParentReportID,
buildOptimisticInvoiceReport,
getInvoiceChatByParticipants,
shouldShowMerchantColumn,
isCurrentUserInvoiceReceiver,
isDraftReport,
changeMoneyRequestHoldStatus,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import getDistanceInMeters from './getDistanceInMeters';
type TransactionParams = {
amount: number;
currency: string;
reportID: string;
reportID: string | undefined;
comment?: string;
attendees?: Attendee[];
created?: string;
Expand Down
12 changes: 6 additions & 6 deletions src/libs/TripReservationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import type {Reservation, ReservationType} from '@src/types/onyx/Transaction';
import type Transaction from '@src/types/onyx/Transaction';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type IconAsset from '@src/types/utils/IconAsset';
import * as Link from './actions/Link';
import {openTravelDotLink} from './actions/Link';
import Log from './Log';
import Navigation from './Navigation/Navigation';
import * as PolicyUtils from './PolicyUtils';
import {getPolicy} from './PolicyUtils';

let travelSettings: OnyxEntry<TravelSettings>;
Onyx.connect({
Expand Down Expand Up @@ -65,7 +65,7 @@ function getTripReservationIcon(reservationType?: ReservationType): IconAsset {
}
}

type ReservationData = {reservation: Reservation; transactionID: string; reportID: string; reservationIndex: number};
type ReservationData = {reservation: Reservation; transactionID: string; reportID: string | undefined; reservationIndex: number};

function getReservationsFromTripTransactions(transactions: Transaction[]): ReservationData[] {
return transactions
Expand Down Expand Up @@ -100,9 +100,9 @@ function bookATrip(translate: LocaleContextProps['translate'], setCtaErrorMessag
setCtaErrorMessage(translate('travel.phoneError'));
return;
}
const policy = PolicyUtils.getPolicy(activePolicyID);
const policy = getPolicy(activePolicyID);
if (isEmptyObject(policy?.address)) {
Navigation.navigate(ROUTES.WORKSPACE_PROFILE_ADDRESS.getRoute(activePolicyID ?? '-1', Navigation.getActiveRoute()));
Navigation.navigate(ROUTES.WORKSPACE_PROFILE_ADDRESS.getRoute(activePolicyID, Navigation.getActiveRoute()));
return;
}
if (!travelSettings?.hasAcceptedTerms) {
Expand All @@ -112,7 +112,7 @@ function bookATrip(translate: LocaleContextProps['translate'], setCtaErrorMessag
if (ctaErrorMessage) {
setCtaErrorMessage('');
}
Link.openTravelDotLink(activePolicyID)
openTravelDotLink(activePolicyID)
?.then(() => {
if (!NativeModules.HybridAppModule || !isSingleNewDotEntry) {
return;
Expand Down
Loading