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
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
import {unholdRequest} from './actions/IOU/Hold';
import {canApproveIOU, canIOUBePaid, canSubmitReport, getBadgeFromIOUReport, getIOUReportActionWithBadge} from './actions/IOU/ReportWorkflow';
import {createDraftWorkspace} from './actions/Policy/Policy';
import {hasCreditBankAccount} from './actions/ReimbursementAccount/store';
import hasCreditBankAccount from './actions/ReimbursementAccount/hasCreditBankAccount';
import {openUnreportedExpense} from './actions/Report';
import type {GuidedSetupData, TaskForParameters} from './actions/Report';
import {isAnonymousUser as isAnonymousUserSession} from './actions/Session';
Expand Down Expand Up @@ -1037,7 +1037,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1040 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1045,7 +1045,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1048 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -1063,7 +1063,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1066 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (deprecatedCurrentUserAccountID) {
Expand All @@ -1075,7 +1075,7 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 1078 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1083,7 +1083,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1086 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1093,7 +1093,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1096 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1101,7 +1101,7 @@

let deprecatedAllReports: OnyxCollection<Report>;
let deprecatedReportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 1104 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1137,14 +1137,14 @@
});

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({

Check warning on line 1140 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETA_CONFIGURATION,
callback: (value) => (betaConfiguration = value ?? {}),
});

let deprecatedAllTransactions: OnyxCollection<Transaction> = {};
let deprecatedReportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1147 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1170,7 +1170,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1173 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/BankAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ import {setBankAccountSubStep} from './ReimbursementAccount';

export {
goToWithdrawalAccountSetupStep,
setBankAccountFormValidationErrors,
resetReimbursementAccount,
resetUSDBankAccount,
resetNonUSDBankAccount,
hideBankAccountErrors,
Expand Down
35 changes: 0 additions & 35 deletions src/libs/actions/CompanyCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ function setAssignCardStepAndData({cardToAssign, isEditing, currentStep, isRefre
Onyx.merge(ONYXKEYS.ASSIGN_CARD, {cardToAssign, isEditing, currentStep, isRefreshing});
}

function setTransactionStartDate(startDate: string) {
Onyx.merge(ONYXKEYS.ASSIGN_CARD, {startDate});
}

function clearAssignCardStepAndData() {
Onyx.set(ONYXKEYS.ASSIGN_CARD, {});
}
Expand Down Expand Up @@ -1025,35 +1021,6 @@ function openPolicyCompanyCardsFeed(domainAccountID: number, policyID: string, f
API.read(READ_COMMANDS.OPEN_POLICY_COMPANY_CARDS_FEED, parameters, {optimisticData, successData, failureData});
}

function openAssignFeedCardPage(policyID: string, feed: CompanyCardFeedWithNumber, domainOrWorkspaceAccountID: number) {
const parameters: OpenPolicyCompanyCardsFeedParams = {
policyID,
feed,
};

const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`,
value: {
isLoading: true,
},
},
];

const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`,
value: {
isLoading: false,
},
},
];

API.read(READ_COMMANDS.OPEN_ASSIGN_FEED_CARD_PAGE, parameters, {optimisticData, finallyData});
}

function openPolicyAddCardFeedPage(policyID: string | undefined) {
if (!policyID) {
return;
Expand Down Expand Up @@ -1425,9 +1392,7 @@ export {
clearAddNewCardFlow,
setAssignCardStepAndData,
clearAssignCardStepAndData,
openAssignFeedCardPage,
openPolicyAddCardFeedPage,
setTransactionStartDate,
setFeedStatementPeriodEndDay,
importCSVCompanyCards,
clearErrorField,
Expand Down
37 changes: 0 additions & 37 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ type IsConnectedAsDelegateParams = WithDelegatedAccess;
// Connect as delegate
type ConnectParams = WithEmail & WithDelegatedAccess & WithOldDotFlag & WithCredentials & WithSession & WithActivePolicyID;

// Clear pending action for role update
type ClearDelegateRolePendingActionParams = WithEmail & WithDelegatedAccess;

/**
* Connects the user as a delegate to another account.
* Returns a Promise that resolves to true on success, false on failure, or undefined if not applicable.
Expand Down Expand Up @@ -332,10 +329,6 @@ function clearDelegatorErrors({delegatedAccess}: ClearDelegatorErrorsParams) {
Onyx.merge(ONYXKEYS.ACCOUNT, {delegatedAccess: {delegators: delegatedAccess.delegators.map((delegator) => ({...delegator, errorFields: undefined}))}});
}

function requestValidationCode() {
API.write(WRITE_COMMANDS.RESEND_VALIDATE_CODE, null);
}

function addDelegate({email, role, validateCode, delegatedAccess}: AddDelegateParams) {
if (!delegatedAccess?.delegates) {
return;
Expand Down Expand Up @@ -669,34 +662,6 @@ function updateDelegateRole({email, role, validateCode, delegatedAccess}: Update
API.write(WRITE_COMMANDS.UPDATE_DELEGATE_ROLE, parameters, {optimisticData, successData, failureData});
}

function clearDelegateRolePendingAction({email, delegatedAccess}: ClearDelegateRolePendingActionParams) {
if (!delegatedAccess?.delegates) {
return;
}

const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.ACCOUNT>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
delegatedAccess: {
delegates: delegatedAccess.delegates.map((delegate) =>
delegate.email === email
? {
...delegate,
pendingAction: null,
pendingFields: undefined,
}
: delegate,
),
},
},
},
];

Onyx.update(optimisticData);
}

function restoreDelegateSession<TKey extends OnyxKey>(authenticateResponse: Response<TKey>) {
Onyx.clear(KEYS_TO_PRESERVE_DELEGATE_ACCESS).then(() => {
updateSessionAuthTokens(authenticateResponse?.authToken, authenticateResponse?.encryptedAuthToken);
Expand All @@ -719,11 +684,9 @@ export {
disconnect,
clearDelegatorErrors,
addDelegate,
requestValidationCode,
clearDelegateErrorsByField,
restoreDelegateSession,
isConnectedAsDelegate,
clearDelegateRolePendingAction,
updateDelegateRole,
removeDelegate,
openSecuritySettingsPage,
Expand Down
10 changes: 1 addition & 9 deletions src/libs/actions/HybridApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,6 @@ function setUseNewDotSignInPage(useNewDotSignInPage: boolean) {
return Onyx.merge(ONYXKEYS.HYBRID_APP, {useNewDotSignInPage});
}

function setClosingReactNativeApp(closingReactNativeApp: boolean) {
// This value is only relevant for HybridApp, so we can skip it in other environments.
if (!CONFIG.IS_HYBRID_APP) {
return;
}
Onyx.merge(ONYXKEYS.HYBRID_APP, {closingReactNativeApp});
}

/*
* Starts HybridApp sign-in flow from the beginning.
*/
Expand All @@ -154,4 +146,4 @@ function resetSignInFlow() {
});
}

export {getHybridAppSettings, setReadyToShowAuthScreens, resetSignInFlow, setUseNewDotSignInPage, setClosingReactNativeApp, closeReactNativeApp};
export {getHybridAppSettings, setReadyToShowAuthScreens, resetSignInFlow, setUseNewDotSignInPage, closeReactNativeApp};
2 changes: 1 addition & 1 deletion src/libs/actions/IOU/BulkEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,5 +580,5 @@ function updateBulkEditDraftTransaction(transactionChanges: NullishDeep<OnyxType
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_BULK_EDIT_TRANSACTION_ID}`, transactionChanges);
}

export {removeUnchangedBulkEditFields, updateMultipleMoneyRequests, initBulkEditDraftTransaction, clearBulkEditDraftTransaction, updateBulkEditDraftTransaction};
export {updateMultipleMoneyRequests, initBulkEditDraftTransaction, clearBulkEditDraftTransaction, updateBulkEditDraftTransaction};
export type {UpdateMultipleMoneyRequestsParams};
2 changes: 1 addition & 1 deletion src/libs/actions/IOU/PayMoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,5 +886,5 @@ function savePreferredPaymentMethod(
});
}

export {cancelPayment, completePaymentOnboarding, getPayMoneyRequestParams, payInvoice, payMoneyRequest, savePreferredPaymentMethod};
export {cancelPayment, completePaymentOnboarding, payInvoice, payMoneyRequest, savePreferredPaymentMethod};
export type {PayInvoiceArgs, PayMoneyRequestData, PayMoneyRequestFunctionParams};
5 changes: 0 additions & 5 deletions src/libs/actions/IOU/TrackExpense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2751,16 +2751,11 @@ function deleteTrackExpense({
}

export {
addTrackedExpenseToPolicy,
buildOnyxDataForTrackExpense,
categorizeTrackedExpense,
convertBulkTrackedExpensesToIOU,
convertTrackedExpenseToRequest,
deleteTrackExpense,
getDeleteTrackExpenseInformation,
getNavigationUrlAfterTrackExpenseDelete,
getTrackExpenseInformation,
shareTrackedExpense,
trackExpense,
requestMoney,
};
Expand Down
8 changes: 0 additions & 8 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
getParsedComment,
getReportNotificationPreference,
getReportOrDraftReport,
hasOutstandingChildRequest,
hasViolations as hasViolationsReportUtils,
isDeprecatedGroupDM,
isExpenseReport,
Expand Down Expand Up @@ -573,10 +572,6 @@ function getUserAccountID(): number {
return deprecatedUserAccountID;
}

function getCurrentUserPersonalDetails(): OnyxEntry<OnyxTypes.PersonalDetails> {
return deprecatedCurrentUserPersonalDetails;
}

Comment on lines -576 to -579

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.

@DylanDylann I saw you added this last week. It's currently unused. Do you plan to use it in the future?

cc @shubham1206agra

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.

Let's remove it, I will add it when using later

function getRecentAttendees(): OnyxEntry<Attendee[]> {
return recentAttendees;
}
Expand Down Expand Up @@ -3780,7 +3775,6 @@ export {
calculateDiffAmount,
getUpdatedMoneyRequestReportData,
startDistanceRequest,
hasOutstandingChildRequest,
getReportPreviewAction,
mergePolicyRecentlyUsedCurrencies,
mergePolicyRecentlyUsedCategories,
Expand All @@ -3792,14 +3786,12 @@ export {
getAllReportNameValuePairs,
getAllTransactionDrafts,
getCurrentUserEmail,
getCurrentUserPersonalDetails,
getUserAccountID,
getRecentAttendees,
getReceiptError,
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
// eslint-disable-next-line @typescript-eslint/no-deprecated
getPolicyTagsData,
maybeUpdateReportNameForFormulaTitle,
getSearchOnyxUpdate,
getPolicyTags,
// eslint-disable-next-line @typescript-eslint/no-deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {OnyxUpdatesFromServer, Response} from '@src/types/onyx';
import {isValidOnyxUpdateFromServer} from '@src/types/onyx/OnyxUpdatesFromServer';
// eslint-disable-next-line import/no-cycle
import {validateAndApplyDeferredUpdates} from '.';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let missingOnyxUpdatesQueryPromise: Promise<Response<any> | Array<Response<any>> | void> | undefined;
Expand Down Expand Up @@ -59,17 +57,6 @@ function isEmpty() {
return Object.keys(deferredUpdates).length === 0;
}

/**
* Manually processes and applies the updates from the deferred updates queue. (used e.g. for push notifications)
*/
function process() {
if (missingOnyxUpdatesQueryPromise) {
missingOnyxUpdatesQueryPromise.finally(() => validateAndApplyDeferredUpdates);
}

missingOnyxUpdatesQueryPromise = validateAndApplyDeferredUpdates();
}

type EnqueueDeferredOnyxUpdatesOptions = {
shouldPauseSequentialQueue?: boolean;
};
Expand Down Expand Up @@ -129,4 +116,4 @@ function clear(options?: ClearDeferredOnyxUpdatesOptions) {
}
}

export {getMissingOnyxUpdatesQueryPromise, setMissingOnyxUpdatesQueryPromise, getUpdates, isEmpty, process, enqueue, clear};
export {getMissingOnyxUpdatesQueryPromise, setMissingOnyxUpdatesQueryPromise, getUpdates, isEmpty, enqueue, clear};
21 changes: 0 additions & 21 deletions src/libs/actions/PersonalDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,26 +505,6 @@ function deleteAvatar(currentUserPersonalDetails: Pick<CurrentUserPersonalDetail
API.write(WRITE_COMMANDS.DELETE_USER_AVATAR, null, {optimisticData, failureData});
}

/**
* Clear error and pending fields for the current user's avatar
*/
function clearAvatarErrors(currentUserAccountID: number) {
if (!currentUserAccountID) {
return;
}

Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {
[currentUserAccountID]: {
errorFields: {
avatar: null,
},
pendingFields: {
avatar: null,
},
},
});
}

/**
* Clear errors for the current user's personal details
*/
Expand Down Expand Up @@ -563,7 +543,6 @@ function updatePersonalDetailsAndShipExpensifyCards(values: FormOnyxValues<typeo
}

export {
clearAvatarErrors,
deleteAvatar,
openPublicProfilePage,
updateAddress,
Expand Down
1 change: 0 additions & 1 deletion src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7103,7 +7103,6 @@ function setWorkspaceConfirmationCurrency(currency: string) {
export {
leaveWorkspace,
addBillingCardAndRequestPolicyOwnerChange,
hasActiveChatEnabledPolicies,
deleteWorkspace,
updateAddress,
updateLastAccessedWorkspace,
Expand Down
5 changes: 0 additions & 5 deletions src/libs/actions/Policy/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,6 @@ function setImportedSpreadsheetIsGLAdjacent(isGLAdjacent: boolean) {
Onyx.merge(ONYXKEYS.IMPORTED_SPREADSHEET, {isGLAdjacent});
}

function setImportedSpreadsheetFileURI(fileURI: string) {
Onyx.merge(ONYXKEYS.IMPORTED_SPREADSHEET, {fileURI});
}

function importMultiLevelTags(policyID: string, spreadsheet: ImportedSpreadsheet | undefined) {
if (!spreadsheet) {
return;
Expand Down Expand Up @@ -1348,6 +1344,5 @@ export {
setImportedSpreadsheetIsImportingIndependentMultiLevelTags,
setImportedSpreadsheetIsFirstLineHeader,
setImportedSpreadsheetIsGLAdjacent,
setImportedSpreadsheetFileURI,
importMultiLevelTags,
};
3 changes: 2 additions & 1 deletion src/libs/actions/QuickActionNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ function navigateToQuickAction(params: NavigateToQuickActionParams) {
default:
}
}
export {navigateToQuickAction, getQuickActionRequestType};
// eslint-disable-next-line import/prefer-default-export
export {navigateToQuickAction};
24 changes: 0 additions & 24 deletions src/libs/actions/ReimbursementAccount/errors.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ function hasCreditBankAccount(bankAccountList: OnyxEntry<OnyxTypes.BankAccountLi
});
}

export default {hasCreditBankAccount};
export {hasCreditBankAccount};
export default hasCreditBankAccount;
Loading
Loading