Skip to content

Commit

Permalink
Merge pull request #29739 from dukenv0307/fix/28641
Browse files Browse the repository at this point in the history
Open the correct report when access sub report page by deep link
  • Loading branch information
madmax330 committed Oct 19, 2023
2 parents 18acd82 + a590cdd commit 84be670
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 @@ -7,7 +7,6 @@ import * as ReportUtils from '../../ReportUtils';
import reportPropTypes from '../../../pages/reportPropTypes';
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 @@ -62,16 +61,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 @@ -4097,4 +4097,5 @@ export {
isWaitingForTaskCompleteFromAssignee,
isReportDraft,
shouldUseFullTitleToDisplay,
parseReportRouteParams,
};

0 comments on commit 84be670

Please sign in to comment.