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
8 changes: 0 additions & 8 deletions config/eslint/eslint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,8 @@
"../../src/components/MultifactorAuthentication/components/OutcomeScreen/OutcomeScreenBase.tsx" "no-restricted-imports" 1
"../../src/components/MultifactorAuthentication/config/scenarios/ChangePIN.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/MultifactorAuthentication/config/scenarios/DefaultUserInterface.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/Navigation/NavigationTabBar/InboxTabButton.tsx" "rulesdir/no-useOnyx-dependencies-arg" 2
"../../src/components/Navigation/QuickCreationActionsBar/index.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/Navigation/QuickCreationActionsBar/index.tsx" "no-restricted-imports" 2
"../../src/components/Navigation/QuickCreationActionsBar/index.tsx" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/components/Navigation/TopLevelNavigationTabBar/index.tsx" "react-hooks/set-state-in-effect" 1
"../../src/components/NumberWithSymbolForm.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/NumberWithSymbolForm.tsx" "react-hooks/set-state-in-effect" 2
Expand Down Expand Up @@ -1008,11 +1006,8 @@
"../../src/pages/Debug/DebugDetails.tsx" "@typescript-eslint/no-unsafe-type-assertion" 9
"../../src/pages/Debug/DebugJSON.tsx" "no-restricted-imports" 1
"../../src/pages/Debug/Report/DebugReportActions.tsx" "no-restricted-imports" 1
"../../src/pages/Debug/Report/DebugReportActions.tsx" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/pages/Debug/Report/DebugReportPage.tsx" "no-restricted-imports" 1
"../../src/pages/Debug/Report/DebugReportPage.tsx" "rulesdir/no-useOnyx-dependencies-arg" 2
"../../src/pages/Debug/ReportAction/DebugReportActionCreatePage.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../src/pages/Debug/ReportAction/DebugReportActionPage.tsx" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/pages/Debug/ReportAction/DebugReportActionPreview.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/pages/Debug/Transaction/DebugTransactionViolations.tsx" "no-restricted-imports" 1
"../../src/pages/Debug/Transaction/DebugTransactionViolations.tsx" "no-restricted-syntax" 1
Expand Down Expand Up @@ -1154,7 +1149,6 @@
"../../src/pages/Travel/DynamicTravelUpgrade.tsx" "no-restricted-imports" 1
"../../src/pages/Travel/ManageTrips.tsx" "no-restricted-imports" 1
"../../src/pages/Travel/TravelUpgrade.tsx" "react-hooks/set-state-in-effect" 1
"../../src/pages/Travel/TripDetailsPage.tsx" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/pages/Travel/WorkspaceConfirmationForTravelPage.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/pages/TripChatNameEditPage.tsx" "@typescript-eslint/no-deprecated/deprecatedGetReportName" 1
"../../src/pages/UnreportedExpenseListItem.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
Expand Down Expand Up @@ -1229,7 +1223,6 @@
"../../src/pages/inbox/report/withReportOrNotFound.tsx" "react-hooks/refs" 3
"../../src/pages/inbox/sidebar/FABPopoverContent/FABFocusableMenuItem.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/pages/inbox/sidebar/FABPopoverContent/menuItems/InvoiceMenuItem.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/pages/inbox/sidebar/FABPopoverContent/menuItems/NewWorkspaceMenuItem.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/pages/inbox/sidebar/FABPopoverContent/menuItems/QuickActionMenuItem.tsx" "@typescript-eslint/no-deprecated/deprecatedGetReportName" 2
Expand Down Expand Up @@ -1365,7 +1358,6 @@
"../../src/pages/settings/Wallet/ExpensifyCardPage/ChangePINPage.tsx" "no-restricted-imports" 1
"../../src/pages/settings/Wallet/ExpensifyCardPage/index.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 2
"../../src/pages/settings/Wallet/ExpensifyCardPage/index.tsx" "no-restricted-imports" 1
"../../src/pages/settings/Wallet/ExpensifyCardPage/index.tsx" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/pages/settings/Wallet/InternationalDepositAccount/PersonalInfo/PersonalInfo.tsx" "@typescript-eslint/no-deprecated/useSubStep" 1
"../../src/pages/settings/Wallet/InternationalDepositAccount/PersonalInfo/substeps/AddressStep.tsx" "@typescript-eslint/no-unsafe-type-assertion" 6
"../../src/pages/settings/Wallet/InternationalDepositAccount/PersonalInfo/substeps/AddressStep.tsx" "react-hooks/set-state-in-effect" 1
Expand Down
10 changes: 4 additions & 6 deletions src/components/Navigation/NavigationTabBar/InboxTabButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,11 @@ function WideInboxTabButton({selectedTab, statusIndicatorColor, accessibilityLab
return getStringParam(route?.params, 'reportActionID');
});

const [doesLastReportExist] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${lastReportRouteReportID}`, {selector: doesLastReportExistSelector}, [lastReportRouteReportID]);
const [doesLastReportExist] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${lastReportRouteReportID}`, {selector: doesLastReportExistSelector});

const doesLastReportActionExistSelector = makeDoesLastReportActionExistSelector(lastReportRouteReportActionID);
const [doesLastReportActionExist] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${lastReportRouteReportID}`, {selector: doesLastReportActionExistSelector}, [
lastReportRouteReportID,
lastReportRouteReportActionID,
]);
const [doesLastReportActionExist] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${lastReportRouteReportID}`, {
selector: makeDoesLastReportActionExistSelector(lastReportRouteReportActionID),
});

const navigateToChats = () => {
if (selectedTab === NAVIGATION_TABS.INBOX) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/Navigation/QuickCreationActionsBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ function QuickCreationActionsBar() {
const hasViolations = hasViolationsReportUtils(undefined, transactionViolations, session?.accountID ?? CONST.DEFAULT_NUMBER_ID, session?.email ?? '');
const {shouldNavigateToUpgradePath} = usePolicyForMovingExpenses();
const isSubmit2026BetaEnabled = isBetaEnabled(CONST.BETAS.SUBMIT_2026);
const groupPoliciesWithChatEnabledSelector = (policies: OnyxCollection<OnyxTypes.Policy>) => getGroupPoliciesWhereReportCanBeCreated(policies, isSubmit2026BetaEnabled, email);
const [groupPoliciesWithChatEnabled = CONST.EMPTY_ARRAY] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: groupPoliciesWithChatEnabledSelector}, [email, isSubmit2026BetaEnabled]);
const [groupPoliciesWithChatEnabled = CONST.EMPTY_ARRAY] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {
selector: (policies: OnyxCollection<OnyxTypes.Policy>) => getGroupPoliciesWhereReportCanBeCreated(policies, isSubmit2026BetaEnabled, email),
});
const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});

const defaultChatEnabledPolicy = useMemo(
Expand Down
17 changes: 3 additions & 14 deletions src/pages/Debug/Report/DebugReportActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,9 @@ function DebugReportActions({reportID}: DebugReportActionsProps) {
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const reportAttributes = useReportAttributes();

const getSortedAllReportActionsSelector = useCallback(
(allReportActions: OnyxEntry<ReportActions>): ReportAction[] => {
return getSortedReportActionsForDisplay(allReportActions, ifUserCanPerformWriteAction, true, undefined, reportID);
},
[ifUserCanPerformWriteAction, reportID],
);

const [sortedAllReportActions] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
{
selector: getSortedAllReportActionsSelector,
},
[getSortedAllReportActionsSelector],
);
const [sortedAllReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
selector: (allReportActions: OnyxEntry<ReportActions>): ReportAction[] => getSortedReportActionsForDisplay(allReportActions, ifUserCanPerformWriteAction, true, undefined, reportID),
});
const participantAccountIDs = getParticipantsAccountIDsForDisplay(report, undefined, undefined, true);
const participantPersonalDetailList = Object.values(getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails));

Expand Down
14 changes: 4 additions & 10 deletions src/pages/Debug/Report/DebugReportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,9 @@ function DebugReportPage({
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION);
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const {isOffline} = useNetwork();
const reportAttributesSelector = useCallback((attributes: OnyxEntry<ReportAttributesDerivedValue>) => attributes?.reports?.[reportID], [reportID]);
const [reportAttributes] = useOnyx(
ONYXKEYS.DERIVED.REPORT_ATTRIBUTES,
{
selector: reportAttributesSelector,
},
[reportAttributesSelector],
);
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {
selector: (attributes: OnyxEntry<ReportAttributesDerivedValue>) => attributes?.reports?.[reportID],
});
const [draftComment] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`);
const [priorityMode] = useOnyx(ONYXKEYS.NVP_PRIORITY_MODE);
const [betas] = useOnyx(ONYXKEYS.BETAS);
Expand All @@ -88,8 +83,7 @@ function DebugReportPage({
const currentUserPersonalDetail = useCurrentUserPersonalDetails();
const {accountID: currentUserAccountID, login: currentUserLogin} = currentUserPersonalDetail;
const [conciergePersonalDetail] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: conciergePersonalDetailSelector});
const reportOwnerSelector = useMemo(() => personalDetailsSelector(report?.ownerAccountID), [report?.ownerAccountID]);
const [reportOwnerPersonalDetail] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: reportOwnerSelector}, [reportOwnerSelector]);
const [reportOwnerPersonalDetail] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsSelector(report?.ownerAccountID)});
const transactionID = DebugUtils.getTransactionID(report, reportActions);
const isReportArchived = useReportIsArchived(reportID);

Expand Down
17 changes: 3 additions & 14 deletions src/pages/Debug/ReportAction/DebugReportActionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,9 @@ function DebugReportActionPage({
const {translate} = useLocalize();
const styles = useThemeStyles();

const getReportActionSelector = useCallback(
(reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportAction> => {
return withDEWRoutedActionsObject(reportActions)?.[reportActionID];
},
[reportActionID],
);

const [reportAction] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
{
selector: getReportActionSelector,
},
[getReportActionSelector],
);
const [reportAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
selector: (reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportAction> => withDEWRoutedActionsObject(reportActions)?.[reportActionID],
});
const transactionID = getLinkedTransactionID(reportAction);

const DebugDetailsTab = useCallback(
Expand Down
12 changes: 6 additions & 6 deletions src/pages/Travel/TripDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type {PersonalDetailsList} from '@src/types/onyx';
import type {Reservation} from '@src/types/onyx/Transaction';

import type {StackScreenProps} from '@react-navigation/stack';
import type {OnyxEntry} from 'react-native-onyx';
Expand All @@ -37,8 +36,8 @@ import FlightTripDetails from './FlightTripDetails';
import HotelTripDetails from './HotelTripDetails';
import TrainTripDetails from './TrainTripDetails';

function pickTravelerPersonalDetails(personalDetails: OnyxEntry<PersonalDetailsList>, reservation: Reservation | undefined) {
return Object.values(personalDetails ?? {})?.find((personalDetail) => personalDetail?.login === reservation?.travelerPersonalInfo?.email);
function pickTravelerPersonalDetails(personalDetails: OnyxEntry<PersonalDetailsList>, travelerEmail: string | undefined) {
return Object.values(personalDetails ?? {})?.find((personalDetail) => personalDetail?.login === travelerEmail);
}

type TripDetailsPageProps = StackScreenProps<TravelNavigatorParamList, typeof SCREENS.TRAVEL.TRIP_DETAILS>;
Expand Down Expand Up @@ -81,9 +80,10 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
const tripReservations = getReservationsFromTripReport(!Number(pnr) && transaction ? undefined : parentReport, transaction ? [transaction] : []);

const {reservation, prevReservation, reservationType, reservationIcon, isCancelled} = getReservationDetailsFromSequence(icons, tripReservations, Number(sequenceIndex));
const travelerPersonalDetailsSelector = (personalDetails: OnyxEntry<PersonalDetailsList>) => pickTravelerPersonalDetails(personalDetails, reservation);

const [travelerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: travelerPersonalDetailsSelector}, [travelerPersonalDetailsSelector]);
const travelerEmail = reservation?.travelerPersonalInfo?.email;
const [travelerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {
selector: (personalDetails: OnyxEntry<PersonalDetailsList>) => pickTravelerPersonalDetails(personalDetails, travelerEmail),
});

return (
<ScreenWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function CreateReportMenuItem() {
const {isBetaEnabled} = usePermissions();
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const hasViolations = hasViolationsReportUtils(undefined, transactionViolations, session?.accountID ?? CONST.DEFAULT_NUMBER_ID, session?.email ?? '');
const chatEnabledPaidGroupPolicies = (policies: Parameters<typeof chatEnabledPaidGroupPoliciesSelector>[0]) => chatEnabledPaidGroupPoliciesSelector(policies, session?.email);

const [groupPoliciesWithChatEnabled = CONST.EMPTY_ARRAY] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: chatEnabledPaidGroupPolicies}, [session?.email]);
const [groupPoliciesWithChatEnabled = CONST.EMPTY_ARRAY] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {
selector: (policies: Parameters<typeof chatEnabledPaidGroupPoliciesSelector>[0]) => chatEnabledPaidGroupPoliciesSelector(policies, session?.email),
});
const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});

const defaultChatEnabledPolicy = getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled as Array<OnyxEntry<OnyxTypes.Policy>>, activePolicy);
Expand Down
8 changes: 3 additions & 5 deletions src/pages/settings/Wallet/ExpensifyCardPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,16 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {

const canManageCardFreeze = isCardHolder && !!currentCard && !isAccountLocked;

const policySelector = useCallback(
(allPolicies: OnyxCollection<Policy>): Policy | undefined => {
const [policyForCurrentCard] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {
selector: (allPolicies: OnyxCollection<Policy>): Policy | undefined => {
const workspaceAccountID = Number(currentCard?.fundID);
if (!workspaceAccountID || Number.isNaN(workspaceAccountID)) {
return undefined;
}

return Object.values(allPolicies ?? {}).find((policy) => policy?.policyAccountID === workspaceAccountID);
},
[currentCard?.fundID],
);
const [policyForCurrentCard] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: policySelector}, [policySelector]);
});
const policyIDForCurrentCard = policyForCurrentCard?.id;
const isWorkspaceAdmin = isPolicyAdmin(policyForCurrentCard, session?.email);
const canUnfreezeCard = canManageCardFreeze && (frozenByAccountID === session?.accountID || isWorkspaceAdmin);
Expand Down
Loading