Skip to content

Commit

Permalink
open the correct report when access sub report page by deep link
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Oct 17, 2023
1 parent cf16dac commit a590cdd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libs/Navigation/AppNavigator/ReportScreenIDSetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import reportPropTypes from '../../../pages/reportPropTypes';
import {withNavigationPropTypes} from '../../../components/withNavigation';
import * as App from '../../actions/App';
import usePermissions from '../../../hooks/usePermissions';
import CONST from '../../../CONST';
import Navigation from '../Navigation';

const propTypes = {
Expand Down Expand Up @@ -60,16 +59,13 @@ const defaultProps = {
* @returns {Number}
*/
const getLastAccessedReportID = (reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom) => {
// If deeplink url is of an attachment, we should show the report that the attachment comes from.
// If deeplink url contains reportID params, we should show the report that has this reportID.
const currentRoute = Navigation.getActiveRoute();
const matches = CONST.REGEX.ATTACHMENT_ROUTE.exec(currentRoute);
const reportID = lodashGet(matches, 1, null);
const {reportID} = ReportUtils.parseReportRouteParams(currentRoute);
if (reportID) {
return reportID;
}

const lastReport = ReportUtils.findLastAccessedReport(reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom);

return lodashGet(lastReport, 'reportID');
};

Expand Down
1 change: 1 addition & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4027,4 +4027,5 @@ export {
isWaitingForTaskCompleteFromAssignee,
isReportDraft,
shouldUseFullTitleToDisplay,
parseReportRouteParams,
};

0 comments on commit a590cdd

Please sign in to comment.