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
1 change: 0 additions & 1 deletion src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,6 @@ const CONST = {
SHOW_HOVER_PREVIEW_DELAY: 270,
SHOW_HOVER_PREVIEW_ANIMATION_DURATION: 250,
ACTIVITY_INDICATOR_TIMEOUT: 10000,
GET_INITIAL_URL_TIMEOUT: 10000,
MIN_SMOOTH_SCROLL_EVENT_THROTTLE: 16,
},
TELEMETRY: {
Expand Down
76 changes: 14 additions & 62 deletions src/DeepLinkHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type DeepLinkHandlerProps = {
*/
function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
const linkingChangeListener = useRef<NativeEventSubscription | null>(null);
const initialUrlProcessed = useRef(false);

const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [, sessionMetadata] = useOnyx(ONYXKEYS.SESSION);
Expand All @@ -38,57 +37,24 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
if (isLoadingOnyxValue(sessionMetadata)) {
return;
}
// If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report
Linking.getInitialURL().then((url) => {
onInitialUrl(url as Route);

// Guard against stale closures: when deps change and the effect re-runs, the previous
// getInitialURL() promise may still be in-flight. Without this guard, its .then() would
// fire with stale conciergeReportID/introSelected values, causing a duplicate
// openReportFromDeepLink() call.
let cancelled = false;

// If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report.
// We race against a timeout to prevent permanently blocking NavigationRoot if getInitialURL() never resolves
// (e.g. in HybridApp when OldDot fails to send the URL via native bridge).
Promise.race([
Linking.getInitialURL(),
new Promise<null>((resolve) => {
setTimeout(() => resolve(null), CONST.TIMING.GET_INITIAL_URL_TIMEOUT);
}),
])
.then((url) => {
if (cancelled) {
return;
if (url) {
if (conciergeReportID === undefined) {
Log.info('[Deep link] conciergeReportID is undefined when processing initial URL', false, {url});
}

initialUrlProcessed.current = true;
onInitialUrl(url as Route);

if (url) {
if (conciergeReportID === undefined) {
Log.info('[Deep link] conciergeReportID is undefined when processing initial URL', false, {url});
}
if (introSelected === undefined) {
Log.info('[Deep link] introSelected is undefined when processing initial URL', false, {url});
}
// Use hasAuthToken() for the latest auth state at call time, since the isAuthenticated
// closure value may be stale on cold start (useOnyx reports 'loaded' before storage completes).
const isCurrentlyAuthenticated = hasAuthToken();
openReportFromDeepLink(url, allReports, isCurrentlyAuthenticated, conciergeReportID, introSelected, betas);
} else {
Report.doneCheckingPublicRoom();
if (introSelected === undefined) {
Log.info('[Deep link] introSelected is undefined when processing initial URL', false, {url});
}

endSpan(CONST.TELEMETRY.SPAN_BOOTSPLASH.DEEP_LINK);
})
.catch(() => {
if (cancelled) {
return;
}

initialUrlProcessed.current = true;
onInitialUrl(null);
openReportFromDeepLink(url, allReports, isAuthenticated, conciergeReportID, introSelected, betas);
} else {
Report.doneCheckingPublicRoom();
endSpan(CONST.TELEMETRY.SPAN_BOOTSPLASH.DEEP_LINK);
});
}

endSpan(CONST.TELEMETRY.SPAN_BOOTSPLASH.DEEP_LINK);
});

// Open chat report from a deep link (only mobile native)
linkingChangeListener.current = Linking.addEventListener('url', (state) => {
Expand All @@ -103,25 +69,11 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
});

return () => {
cancelled = true;
linkingChangeListener.current?.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps -- we only want this effect to re-run when conciergeReportID changes
}, [sessionMetadata?.status, conciergeReportID, introSelected, betas]);

// Safety net: if getInitialURL() resolves before the session loads, hasAuthToken() may return false
// for an authenticated user, causing openReportFromDeepLink to take the wrong path. Once isAuthenticated
// settles to true, unblock the UI. The initialUrlProcessed guard ensures this doesn't fire before URL
// resolution. In the common case (isAuthenticated settles first), this is a no-op because
// openReportFromDeepLink's own doneCheckingPublicRoom() call handles it.
useEffect(() => {
if (!isAuthenticated || !initialUrlProcessed.current) {
return;
}

Report.doneCheckingPublicRoom();
}, [isAuthenticated]);

return null;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function Expensify() {
const {preferredLocale} = useLocalize();
const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector});
const [lastRoute] = useOnyx(ONYXKEYS.LAST_ROUTE);
const [isCheckingPublicRoom = true] = useOnyx(ONYXKEYS.RAM_ONLY_IS_CHECKING_PUBLIC_ROOM);
const [updateAvailable] = useOnyx(ONYXKEYS.RAM_ONLY_UPDATE_AVAILABLE);
const [updateRequired] = useOnyx(ONYXKEYS.RAM_ONLY_UPDATE_REQUIRED);
const [isCheckingPublicRoom = true] = useOnyx(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, {initWithStoredValues: false});
const [updateAvailable] = useOnyx(ONYXKEYS.UPDATE_AVAILABLE, {initWithStoredValues: false});
const [updateRequired] = useOnyx(ONYXKEYS.UPDATE_REQUIRED, {initWithStoredValues: false});
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);

useDebugShortcut();
Expand All @@ -81,7 +81,7 @@ function Expensify() {

const bootsplashSpan = useRef<Sentry.Span>(null);

const [initialUrl, setInitialUrl] = useState<Route | null | undefined>(undefined);
const [initialUrl, setInitialUrl] = useState<Route | null>(null);
const {setIsAuthenticatedAtStartup} = useInitialURLActions();

useEffect(() => {
Expand Down Expand Up @@ -302,7 +302,7 @@ function Expensify() {
<FullstoryInitHandler />
<DeepLinkHandler onInitialUrl={setInitialUrl} />
<AppleAuthWrapper />
{hasAttemptedToOpenPublicRoom && initialUrl !== undefined && (
{hasAttemptedToOpenPublicRoom && (
<NavigationRoot
onReady={setNavigationReady}
authenticated={isAuthenticated}
Expand Down
20 changes: 10 additions & 10 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ONYXKEYS = {
IS_SIDEBAR_LOADED: 'isSidebarLoaded',

/** Boolean flag set whenever we are searching for reports in the server */
RAM_ONLY_IS_SEARCHING_FOR_REPORTS: 'isSearchingForReports',
IS_SEARCHING_FOR_REPORTS: 'isSearchingForReports',

/** Note: These are Persisted Requests - not all requests in the main queue as the key name might lead one to believe */
PERSISTED_REQUESTS: 'networkRequestQueue',
Expand Down Expand Up @@ -103,7 +103,7 @@ const ONYXKEYS = {
CURRENCY_LIST: 'currencyList',

/** Indicates whether an update is available and ready to be installed. */
RAM_ONLY_UPDATE_AVAILABLE: 'updateAvailable',
UPDATE_AVAILABLE: 'updateAvailable',

/** Indicates that a request to join a screen share with a GuidesPlus agent was received */
SCREEN_SHARE_REQUEST: 'screenShareRequest',
Expand Down Expand Up @@ -327,7 +327,7 @@ const ONYXKEYS = {
USER_METADATA: 'userMetadata',

/** Object containing Onfido SDK Token + applicantID */
RAM_ONLY_WALLET_ONFIDO: 'walletOnfido',
WALLET_ONFIDO: 'walletOnfido',

/** Stores information about additional details form entry */
WALLET_ADDITIONAL_DETAILS: 'walletAdditionalDetails',
Expand Down Expand Up @@ -405,7 +405,7 @@ const ONYXKEYS = {
IS_BETA: 'isBeta',

/** Whether we're checking if the room is public or not */
RAM_ONLY_IS_CHECKING_PUBLIC_ROOM: 'isCheckingPublicRoom',
IS_CHECKING_PUBLIC_ROOM: 'isCheckingPublicRoom',

/** A map of the user's security group IDs they belong to in specific domains */
MY_DOMAIN_SECURITY_GROUPS: 'myDomainSecurityGroups',
Expand Down Expand Up @@ -466,7 +466,7 @@ const ONYXKEYS = {
RECENTLY_USED_REPORT_FIELDS: 'recentlyUsedReportFields',

/** Indicates whether an forced upgrade is required */
RAM_ONLY_UPDATE_REQUIRED: 'updateRequired',
UPDATE_REQUIRED: 'updateRequired',

/** Indicates a global supportal permission denial that should surface a modal */
SUPPORTAL_PERMISSION_DENIED: 'supportalPermissionDenied',
Expand Down Expand Up @@ -1271,7 +1271,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.PERSONAL_DETAILS_METADATA]: Record<string, OnyxTypes.PersonalDetailsMetadata>;
[ONYXKEYS.TASK]: OnyxTypes.Task;
[ONYXKEYS.CURRENCY_LIST]: OnyxTypes.CurrencyList;
[ONYXKEYS.RAM_ONLY_UPDATE_AVAILABLE]: boolean;
[ONYXKEYS.UPDATE_AVAILABLE]: boolean;
[ONYXKEYS.SCREEN_SHARE_REQUEST]: OnyxTypes.ScreenShareRequest;
[ONYXKEYS.COUNTRY_CODE]: number;
[ONYXKEYS.COUNTRY]: string;
Expand Down Expand Up @@ -1326,7 +1326,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.NVP_PRIVATE_BILLING_DISPUTE_PENDING]: number;
[ONYXKEYS.NVP_PRIVATE_BILLING_STATUS]: OnyxTypes.BillingStatus;
[ONYXKEYS.USER_WALLET]: OnyxTypes.UserWallet;
[ONYXKEYS.RAM_ONLY_WALLET_ONFIDO]: OnyxTypes.WalletOnfido;
[ONYXKEYS.WALLET_ONFIDO]: OnyxTypes.WalletOnfido;
[ONYXKEYS.WALLET_ADDITIONAL_DETAILS]: OnyxTypes.WalletAdditionalDetails;
[ONYXKEYS.WALLET_TERMS]: OnyxTypes.WalletTerms;
[ONYXKEYS.BANK_ACCOUNT_LIST]: OnyxTypes.BankAccountList;
Expand Down Expand Up @@ -1355,7 +1355,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID]: string;
[ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT]: boolean;
[ONYXKEYS.IS_BETA]: boolean;
[ONYXKEYS.RAM_ONLY_IS_CHECKING_PUBLIC_ROOM]: boolean;
[ONYXKEYS.IS_CHECKING_PUBLIC_ROOM]: boolean;
[ONYXKEYS.MY_DOMAIN_SECURITY_GROUPS]: Record<string, string>;
[ONYXKEYS.VERIFY_3DS_SUBSCRIPTION]: string;
[ONYXKEYS.PREFERRED_THEME]: ValueOf<typeof CONST.THEME>;
Expand All @@ -1372,10 +1372,10 @@ type OnyxValuesMapping = {
[ONYXKEYS.ONBOARDING_POLICY_ID]: string;
[ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID]: string;
[ONYXKEYS.ONBOARDING_LAST_VISITED_PATH]: string;
[ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS]: boolean;
[ONYXKEYS.IS_SEARCHING_FOR_REPORTS]: boolean;
[ONYXKEYS.LAST_VISITED_PATH]: string | undefined;
[ONYXKEYS.RECENTLY_USED_REPORT_FIELDS]: OnyxTypes.RecentlyUsedReportFields;
[ONYXKEYS.RAM_ONLY_UPDATE_REQUIRED]: boolean;
[ONYXKEYS.UPDATE_REQUIRED]: boolean;
[ONYXKEYS.SUPPORTAL_PERMISSION_DENIED]: OnyxTypes.SupportalPermissionDenied | null;
[ONYXKEYS.RESET_REQUIRED]: boolean;
[ONYXKEYS.PLAID_CURRENT_EVENT]: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function BaseVacationDelegateSelectionComponent({
const styles = useThemeStyles();
const icons = useMemoizedLazyExpensifyIcons(['FallbackAvatar']);
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const [isSearchingForReports] = useOnyx(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});

const currentVacationDelegate = vacationDelegate?.delegate ?? '';
const delegatePersonalDetails = getPersonalDetailByEmail(currentVacationDelegate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function UserSelectPopup({value, closeOverlay, onChange, isSearchable}: UserSele
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST);
const [searchTerm, setSearchTerm] = useState('');
const [isSearchingForReports] = useOnyx(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});

const getInitialSelectedIDs = useCallback(() => {
return value.reduce<Set<string>>((acc, id) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search/SearchFiltersChatsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen
const currentUserAccountID = currentUserPersonalDetails.accountID;
const currentUserEmail = currentUserPersonalDetails.email ?? '';

const [isSearchingForReports] = useOnyx(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const reportAttributesDerived = useReportAttributes();
const [selectedReportIDs, setSelectedReportIDs] = useState<string[]>(initialReportIDs);
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate,
const {options, areOptionsInitialized} = useOptionsList({
shouldInitialize: didScreenTransitionEnd,
});
const [isSearchingForReports] = useOnyx(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const reportAttributesDerived = useReportAttributes();
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
const {setShouldResetSearchQuery} = useSearchActionsContext();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const currentUserAccountID = currentUserPersonalDetails.accountID;
const [isSearchingForReports] = useOnyx(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const personalDetails = usePersonalDetails();
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Onyx.connectWithoutView({

const KEYS_TO_PRESERVE: OnyxKey[] = [
ONYXKEYS.ACCOUNT,
ONYXKEYS.RAM_ONLY_IS_CHECKING_PUBLIC_ROOM,
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
ONYXKEYS.IS_LOADING_APP,
ONYXKEYS.IS_SIDEBAR_LOADED,
ONYXKEYS.MODAL,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/AppUpdate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import updateApp from './updateApp';

function triggerUpdateAvailable() {
Onyx.set(ONYXKEYS.RAM_ONLY_UPDATE_AVAILABLE, true);
Onyx.set(ONYXKEYS.UPDATE_AVAILABLE, true);
}

function setIsAppInBeta(isBeta: boolean) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/QueuedOnyxUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function flushQueue(): Promise<void> {
ONYXKEYS.CREDENTIALS,
ONYXKEYS.IS_SIDEBAR_LOADED,
ONYXKEYS.ACCOUNT,
ONYXKEYS.RAM_ONLY_IS_CHECKING_PUBLIC_ROOM,
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
ONYXKEYS.MODAL,
ONYXKEYS.NETWORK,
ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT,
Expand Down
20 changes: 10 additions & 10 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
// map of reportID to all reportActions for that report
const allReportActions: OnyxCollection<ReportActions> = {};

Onyx.connect({

Check warning on line 376 in src/libs/actions/Report/index.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,
callback: (actions, key) => {
if (!key || !actions) {
Expand All @@ -385,7 +385,7 @@
});

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

Check warning on line 388 in src/libs/actions/Report/index.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 All @@ -394,7 +394,7 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
Onyx.connect({

Check warning on line 397 in src/libs/actions/Report/index.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) => {
allPersonalDetails = value ?? {};
Expand All @@ -412,7 +412,7 @@
});

let onboarding: OnyxEntry<Onboarding>;
Onyx.connect({

Check warning on line 415 in src/libs/actions/Report/index.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.NVP_ONBOARDING,
callback: (val) => {
if (Array.isArray(val)) {
Expand Down Expand Up @@ -1403,7 +1403,7 @@
});
}

const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.RAM_ONLY_IS_CHECKING_PUBLIC_ROOM>> = [];
const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.IS_CHECKING_PUBLIC_ROOM>> = [];

const parameters: OpenReportParams = {
reportID,
Expand Down Expand Up @@ -1670,7 +1670,7 @@
if (isFromDeepLink) {
finallyData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.RAM_ONLY_IS_CHECKING_PUBLIC_ROOM,
key: ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
value: false,
});

Expand Down Expand Up @@ -4233,7 +4233,7 @@
}

function doneCheckingPublicRoom() {
Onyx.set(ONYXKEYS.RAM_ONLY_IS_CHECKING_PUBLIC_ROOM, false);
Onyx.set(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, false);
}

function navigateToMostRecentReport(currentReport: OnyxEntry<Report>, conciergeReportID: string | undefined, currentUserAccountID: number, introSelected: OnyxEntry<IntroSelected>) {
Expand Down Expand Up @@ -5066,22 +5066,22 @@
function searchForReports(isOffline: boolean, searchInput: string, policyID?: string, isUserSearch = false) {
// We do not try to make this request while offline because it sets a loading indicator optimistically
if (isOffline) {
Onyx.set(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS, false);
Onyx.set(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, false);
return;
}

const successData: Array<OnyxUpdate<typeof ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS>> = [
const successData: Array<OnyxUpdate<typeof ONYXKEYS.IS_SEARCHING_FOR_REPORTS>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS,
key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS,
value: false,
},
];

const failureData: Array<OnyxUpdate<typeof ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS>> = [
const failureData: Array<OnyxUpdate<typeof ONYXKEYS.IS_SEARCHING_FOR_REPORTS>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS,
key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS,
value: false,
},
];
Expand All @@ -5105,14 +5105,14 @@
// We are not getting isOffline from components as useEffect change will re-trigger the search on network change
const isOffline = NetworkStore.isOffline();
if (isOffline || !searchInput.trim().length) {
Onyx.set(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS, false);
Onyx.set(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, false);
return;
}

// Why not set this in optimistic data? It won't run until the API request happens and while the API request is debounced
// we want to show the loading state right away. Otherwise, we will see a flashing UI where the client options are sorted and
// tell the user there are no options, then we start searching, and tell them there are no options again.
Onyx.set(ONYXKEYS.RAM_ONLY_IS_SEARCHING_FOR_REPORTS, true);
Onyx.set(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, true);
searchForReports(isOffline, searchInput, policyID, isUserSearch);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/UpdateRequired.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';

function alertUser() {
Onyx.set(ONYXKEYS.RAM_ONLY_UPDATE_REQUIRED, true);
Onyx.set(ONYXKEYS.UPDATE_REQUIRED, true);
}

export {
Expand Down
Loading
Loading