Fix Landing in recent chat that not have if login via link
Details
Landing in recent chat if login via link with user you don't have chat with.
Fixed Issues
$ https://github.com/Expensify/App/issues/17188 PROPOSAL: https://github.com/Expensify/App/issues/17188#issuecomment-1509764446
Tests
- User that not a member of the chat should land in "You don't have access to this chat" when login via link of this chat
- Login with any account
- Open any chat
- Copy the link to the chat
- Log out of the account
- Paste and go to the copied link
- Login with account that doesn't a member of the chat opened before.
- Verify that user lands in "You don't have access to this chat"
- User should be directed to the chat whose reportID is in url/link when login via link that is detail link of the admin room
- Login with any account
- Open an admin room
- Click to header to see detail modal
- Copy the URL
- Go to any other chat
- Log out
- Re-login the same account with the link copied above
- Verify that detail modal is displayed and the chat open is the current chat of the detail modal displayed
- User should be directed to the chat whose reportID is in url/link when login via link that is participant link of the group
- Login with any account
- Open a group
- Click to header to see detail modal
- Copy the URL
- Go to any other chat
- Log out
- Re-login the same account with the link copied above
- Verify that detail modal is displayed and the chat open is the current chat of the detail modal displayed
- [x] Verify that no errors appear in the JS console
Offline tests
Same above
QA Steps
- User that not a member of the chat should land in "You don't have access to this chat" when login via link of this chat
- Login with any account
- Open any chat
- Copy the link to the chat
- Log out of the account
- Paste and go to the copied link
- Login with account that doesn't a member of the chat opened before.
- Verify that user lands in "You don't have access to this chat"
- User should be directed to the chat whose reportID is in url/link when login via link that is participant link of the admin room
- Login with any account
- Open an admin room
- Click to header to see detail modal
- Copy the URL
- Log out
- Re-login the same account with the link copied above
- Verify that detail modal is displayed and the chat open is the current chat of the detail modal displayed
- User should be directed to the chat whose reportID is in url/link when login via link that is detail link of the group room
- Login with any account
- Open a group
- Click to header to see detail modal
- Copy the URL
- Log out
- Re-login the same account with the link copied above
- Verify that detail modal is displayed and the chat open is the current chat of the detail modal displayed
- [ ] Verify that no errors appear in the JS console
PR Author Checklist
- [x] I linked the correct issue in the
### Fixed Issuessection above - [x] I wrote clear testing steps that cover the changes made in this PR
- [x] I added steps for local testing in the
Testssection - [x] I added steps for the expected offline behavior in the
Offline stepssection - [x] I added steps for Staging and/or Production testing in the
QA stepssection - [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- [x] I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
- [x] I added steps for local testing in the
- [x] I included screenshots or videos for tests on all platforms
- [x] I ran the tests on all platforms & verified they passed on:
- [x] Android / native
- [x] Android / Chrome
- [x] iOS / native
- [x] iOS / Safari
- [x] MacOS / Chrome / Safari
- [x] MacOS / Desktop
- [x] I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
- [x] I followed proper code patterns (see Reviewing the code)
- [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
toggleReportand notonIconClick) - [x] I verified that comments were added to code that is not self explanatory
- [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- [x] I verified any copy / text shown in the product is localized by adding it to
src/languages/*files and using the translation method- [x] If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
- [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
- [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the
Waiting for Copylabel for a copy review on the original GH to get the correct copy. - [x] I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
- [x] I verified the JSDocs style guidelines (in
STYLE.md) were followed
- [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I followed the guidelines as stated in the Review Guidelines
- [x] I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarare working as expected) - [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
- [x] I verified that if a function's arguments changed that all usages have also been updated correctly
- [x] If a new component is created I verified that:
- [x] A similar component doesn't exist in the codebase
- [x] All props are defined accurately and each prop has a
/** comment above it */ - [x] The file is named correctly
- [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- [x] The only data being stored in the state is data necessary for rendering and nothing else
- [x] For Class Components, any internal methods passed to components event handlers are bound to
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - [x] Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - [x] All JSX used for rendering exists in the render method
- [x] The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- [x] If any new file was added I verified that:
- [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- [x] If a new CSS style is added I verified that:
- [x] A similar style doesn't already exist
- [x] The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
- [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- [x] If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - [x] If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - [x] I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.
Screenshots/Videos
Web
- User that not a member of the chat should land in "You don't have access to this chat" when login via link of this chat
https://user-images.githubusercontent.com/129500732/234255570-e71d6713-1183-4803-b6b8-f23e163bdcbf.mp4
- User should be directed to the chat whose reportID is in url/link when login via link that is detail link of the admin room
https://user-images.githubusercontent.com/129500732/234255637-376c11d9-4167-4eca-9470-15a89a868806.mp4
- User should be directed to the chat whose reportID is in url/link when login via link that is participant link of the group
https://user-images.githubusercontent.com/129500732/234255687-30534cf1-eb87-4097-85c0-eca686563689.mp4
Mobile Web - Chrome
- User that not a member of the chat should land in "You don't have access to this chat" when login via link of this chat
https://user-images.githubusercontent.com/129500732/234267980-586db94b-aca7-4d43-8ecc-8ed1c388fe4c.mp4
- User should be directed to the chat whose reportID is in url/link when login via link that is detail link of the admin room
https://user-images.githubusercontent.com/129500732/234268005-51cc345f-c0bf-4f43-a25f-ef4f8bc0a1a2.mp4
- User should be directed to the chat whose reportID is in url/link when login via link that is participant link of the group
https://user-images.githubusercontent.com/129500732/234268027-817913dd-dae7-4517-bc84-501346d53013.mp4
Mobile Web - Safari
- User that not a member of the chat should land in "You don't have access to this chat" when login via link of this chat
https://user-images.githubusercontent.com/129500732/234470515-582c02ed-139b-4eec-b551-f5bf69b3cd9d.mp4
- User should be directed to the chat whose reportID is in url/link when login via link that is detail link of the admin room
https://user-images.githubusercontent.com/129500732/234470556-1eba949f-fac7-479f-8c26-90dafffb7a83.mp4
- User should be directed to the chat whose reportID is in url/link when login via link that is participant link of the group
https://user-images.githubusercontent.com/129500732/234470569-c5ddc687-0bde-45a4-970a-41111f2f25e0.mp4
Desktop
Can't open deep link on Desktop
iOS
- User that not a member of the chat should land in "You don't have access to this chat" when login via link of this chat
https://user-images.githubusercontent.com/129500732/234491602-436eb873-c441-4505-93d7-5f8e33ea4878.mp4
-
User should be directed to the chat whose reportID is in url/link when login via link that is detail link of the admin room
-
User should be directed to the chat whose reportID is in url/link when login via link that is participant link of the group
Android
- User that not a member of the chat should land in "You don't have access to this chat" when login via link of this chat
https://user-images.githubusercontent.com/129500732/234473040-fb3d390f-82ac-4c88-9dd0-18b53d608f8f.mp4
-
User should be directed to the chat whose reportID is in url/link when login via link that is detail link of the admin room
-
User should be directed to the chat whose reportID is in url/link when login via link that is participant link of the group
@neil-marcellini Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]
@neil-marcellini The PR is ready to review
@bondydaa I'm assigning you instead since you're CME, IDK why that didn't happen automatically. I'll report that bug in Slack unless someone has already reported it.
pretty sure the link to the issue wasn't right

fixed the issue link
@bondydaa I just updated, plesae check again
@dukenv0307 Changes look good. Can you please update the "Screenshots/Videos" in the PR body to make sure latest changes are working as expected.
Also, please update Test and QA Steps to include more cases (like: navigating to report with chat history, navigating to details/participants of a room or a group).
@sobitneupane I just updated Tests and QA Steps, please check again and I will update the screenshot follow these steps after your confirmation
User should open current chat when
I would prefer "User should be directed to the chat whose reportID is in url/link when". Other than that everything looks great.
@sobitneupane Great, your suggest is clearer, I updated and I'm just updating the screenshot.
@sobitneupane in case 2 and 3, when I open with deeplink it displays a warning is URL contains routes not present in the root navigator like this

So after login success it displays home screen. Can we not update screenshot in native with case 2, 3?
@dukenv0307 Is it present on main as well or is it introduced by this PR? I feel like it is present in main branch as well. In that case, I believe we should hold this PR and test it after the issue gets resolved.
cc: @bondydaa
@sobitneupane I just tested it in main, and it has same issue with deeplink "new-expensify://r/6329260524782826/participants". And It just work with deeplink "new-expensify://r/:reportID"
@bondydaa This PR can not be tested on native due to this issue. Should we hold this PR for the issue to be solved?
@sobitneupane only case 2, 3 have this issue, case 1 could be tested well. I just updated screenshot for all case available in each platform
Hmm sorry for the delay just to confirm on main we get the same Console Warning that show https://github.com/Expensify/App/pull/17699#issuecomment-1521697676 when trying to open a deep link on a native platform, right?
@bondydaa yes, that's right. It shows console warning with deeplink similar in case 2 and 3 of tests
@bondydaa Yes. We get the same warning in main as well. We get the warning when url is in /r/:reportID/participants or /r/:reportID/details format but not on /r/:reportID.
gotcha cool well it's good that we're not adding any new warnings but yeah agree it's not great to have that being thrown.
Looking at these docs looks like we should be able to handle passing and parsing urls https://reactnavigation.org/docs/configuring-links/#passing-params
based on the thread we started here https://expensify.slack.com/archives/C01GTK53T8Q/p1682610734941449?thread_ts=1682549395.857859&cid=C01GTK53T8Q
we should really fix this to no rely on the side effect behavior in componentShouldUpdate which is these lines: https://github.com/Expensify/App/blob/6f0888ca261d12c327852f548350b18b618ba65f/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js#L100-L103
I think this is the file that controls our routes https://github.com/Expensify/App/blob/b7ab83dc7f/src/ROUTES.js, we have the routes for r/:id/details here https://github.com/Expensify/App/blob/b7ab83dc7f4b6f8c5a61fa9b264bbfe4b9d25475/src/ROUTES.js#L108-L111 so not sure why that console warning is showing.
From my testing this previously the url that we have here https://github.com/Expensify/App/blob/f8acfae37e181c66ab9dbf232772bb293c9b159b/src/Expensify.js#L154-L157 is the correct URL after the user logs in, that's why the initial changes to prevent the side effect here worked https://github.com/Expensify/App/commit/5ad832412b565cea7bfe06f429b51387a66a7b1d#diff-8f9a8a3c117992cc124a0ddee7873f2bd67716e041ae611f58bd6915706c277aR111-R114
So the all we need to do is make sure that we are properly loading the most recent report when a link doesn't have a reportID right? I wonder if we can set a default on routes somehow?
@bondydaa Should we hold the PR to fix issue above or continue with it?
Hmm nope i don't see why we should hold this but it should be updated to not store the reportID and instead just rely on the navigation params and routes.
@bondydaa I tried to log state.routes in native and web. I saw that when sign in with deep link r/:reportID/particitant, in web state.routes had two element is home page and participants page while in native it had only home screen althought after login it navigated to correct reportID screen but it display home screen
There are unverified commits in this PR please fix them @dukenv0307
@marcaaron Sorry for the inconvenience, I had to reinstall my laptop and old gpg key is deleted. I updated commit please help to continue review the PR.
@bondydaa I just found out that when user not authenticated, AppNavigator will return PublicScreens and in PublicScreens has SCREENS.HOME that could be why with deep link /r/:reportID it has no warning and other has warning.
@bondydaa
- After finding out, I realized that this is not the issue because when the user doesn't sign in,
AppNavigatorwill renderPublicScreenand it doesn't have the screen's name same asParticipantor other modal screens like that. So, the warning appears when we try to open the app with this deep link. - And I just updated the PR to navigate correctly the deep link after login successfully in native, please check again and I will update the screen if it makes sense.
@dukenv0307 As suggested by @bondydaa here, can we get rid of https://github.com/Expensify/App/blob/6f0888ca261d12c327852f548350b18b618ba65f/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js#L100-L104 part of code (which should automatically solves our issue). This part of code was introduced to redirect user to most recent chat if no reportID supplied in url when user logs in. We should look for a way to set most recent chat's reportID as default reportID.
So the all we need to do is make sure that we are properly loading the most recent report when a link doesn't have a reportID right? I wonder if we can set a default on routes somehow?
@sobitneupane I just foud out that in native after login successfully, the app really automatically navigates to the recent report but drawerContent (SideBarScreen) has default drawerStatus is true that is returned in getDefaultDrawerState function. So that it displays the sidebar instead of the recent report. So, it is a bug or not?
@dukenv0307 Yes. It is expected to open SibeBarScreen instead of recent report in small screen device if no reportID is supplied in url.
@sobitneupane I understand. The latest update in the PR got the expected result please help to check again