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

Prevent It's not here message when logging in #55721 #56228

Merged
Merged
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
15 changes: 15 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import * as Localize from '@libs/Localize';
import Log from '@libs/Log';
import {registerPaginationConfig} from '@libs/Middleware/Pagination';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import shouldOpenOnAdminRoom from '@libs/Navigation/shouldOpenOnAdminRoom';
import {isOnboardingFlowName} from '@libs/NavigationUtils';
import enhanceParameters from '@libs/Network/enhanceParameters';
import type {NetworkStatus} from '@libs/NetworkConnection';
Expand Down Expand Up @@ -2945,6 +2946,20 @@ function openReportFromDeepLink(url: string) {
return;
}

// Check if the report exists in the collection
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
Copy link
Member

@rushatgabhane rushatgabhane Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a noobie questions:
@OmarKoueifi will onyx always have the report at this point in code? Can there be a case where the report is being fetched, so it isn't in onyx. But the report actually exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane
To my understanding and based on my testing, the report should always be in Onyx at this point. However, I’m still new to this project and haven’t explored all edge cases. If there's a scenario where it might not be available yet, I’d love to understand how to reproduce that.

I initially tried another approach using onyx.connect with the key ${ONYXKEYS.COLLECTION.REPORT}${thread.reportID} and checking inside the callback. That seemed to work, but I ultimately went with the current solution since it's being used in many place in code allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];.

I also wanted to add a unit test for this, but I couldn’t find any existing test cases for openReportFromDeepLink. I’m still getting familiar with how tests are structured in this repo, if there’s a recommended place to add it or an example of a similar function with tests, I’d appreciate any guidance!

// If the report does not exist, navigate to the last accessed report or Concierge chat
if (!report) {
const lastAccessedReportID = findLastAccessedReport(false, shouldOpenOnAdminRoom(), undefined, reportID)?.reportID;
if (lastAccessedReportID) {
const lastAccessedReportRoute = ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID);
Navigation.navigate(lastAccessedReportRoute, CONST.NAVIGATION.ACTION_TYPE.PUSH);
return;
}
navigateToConciergeChat(false, () => true, CONST.NAVIGATION.ACTION_TYPE.PUSH);
return;
}

Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH);
};

Expand Down
Loading