[HOLD - App Navigation Reboot] [$500] mWeb- Previous chat username is displayed when you navigate back from different chat @Yash Chauhan & @Puneet-here
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Go to staging.new.expensify.com
- Open the chat area.
- Click on any chat, then navigate back to chat area.
- Click on different chat this time and navigate back and look at top where username is displayed.
- If everything is working fine then repeat steps 2 and 3 again.
Expected Result:
Previous chat username is not displayed when you navigate back from different chat
Actual Result:
Previous chat username is displayed when you navigate back from different chat
Workaround:
Unknown
Platform:
Where is this issue occurring?
- Mobile Web (Android and Safari)
Version Number: 1.1.69.2
Reproducible in staging?: Yes
Reproducible in production?: Yes
Email or phone of affected tester (no customers): any
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
https://user-images.githubusercontent.com/93399543/171181467-a9667a37-9c08-4341-95d0-9797f821e5b0.mp4
Expensify/Expensify Issue URL:
Issue reported by: @ Yash Chauhan @Puneet-here
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1651639523326759
Triggered auto assignment to @CortneyOfstad (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.
Current assignee @CortneyOfstad is eligible for the AutoAssignerTriage assigner, not assigning anyone new.
It was already reported by me here
Triggered auto assignment to @TomatoToaster (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Triggered auto assignment to @bfitzexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
@bfitzexpensify, just noting that that there were two people who reported this bug and the GH body and title were changed to reflect this.
Upwork job here
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (Exported)
Triggered auto assignment to @AndrewGable (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Similar issue happening to me, wondering if I should post a new bug.
- Open new.expensify.com in Safari on iOS
- Navigate to chat
- Hit
<in upper left corner of chat - Be send to sent to previous page instead of to LHN where I should be.
https://user-images.githubusercontent.com/22508304/173427038-068b364d-1743-44b2-981b-2c34304becb8.MP4
cc @kbecciv , @isabelastisser @mvtglobally, I feel like this has been an issue for a while, that was reported before. (the one in the OP and the one I posted here), do you remember seeing others?
@mallenexpensify we are checking closed issues as well. But it has been on a off. I will update shortly
Proposal
Hi, does this issue still require external contributions? Here is my suggestion if needed.
Cause
This problem is because ReportScreen.js takes reportID, report, repostActions from the route params, while the route is changed earlier than the openDrawer executed in web when using the browser's back button (similar to swipe backward).
We can record the process in the chrome dev tools Performance panel.
initial path: /r/95869372
initial username: [email protected]
open the [email protected], then back

Solution
Here are several solutions.
1. Don't render the report in this scenario ( easier )
In this case, the page will display blank instead of the wrong username when backing.
We can do this by judging the context of drawer navigation.

https://user-images.githubusercontent.com/8579651/174061387-5b6975fb-b832-4315-9f96-76f7d156d554.mp4
2.Don't get report from route param
We need add ONYX KEY like previousReportID
can update it when the MainDrawerNavigator is mounted or SidebarLink is clicked.
then, ReportScreen get report from this key

https://user-images.githubusercontent.com/8579651/174061443-f6175bb6-016e-4bb1-9167-2cc2b22d5750.mp4
Maybe there are other solutions, such as changing the routing logic. However, this risk is relatively large and uncontrollable, so it is not recommended.
In general: If an issue has the Help Wanted label, then yes, it still is open for proposals and someone to work on it.
But yes, @mvtglobally can you provide an update for this one? Thanks!
Are you guys been able to consistently reproduce this? I haven't been able to reproduce this on iOS Safari.
@ntdiary Please allow me sometime to go through your proposal, I am trying to reproduce it at my end. Also while I can see you've posted two approaches, can you explain where and how are these changes added? So that it gives me more context on the implementation.
This can be always reproduced, but if your mobile phone has good performance, the time is very short. maybe need to play it at 0.5x speed, after clicking the back button in the video.
https://user-images.githubusercontent.com/8579651/174787732-a7ce564d-c54a-470a-af23-8c499d0fdb54.mov
- Ensure Clear all login information. Then create a new tab
- Login.
- Refresh page.
- click another username. (this user's reportID is different from the reportID in the route path)
- click the bottom back button.
here are main differences: https://github.com/ntdiary/App/blob/ef20ba7f5696202f39648c3451b018caf2a1219e/src/pages/home/ReportScreen.js#L203-L207 first way: https://github.com/ntdiary/App/commit/ef20ba7f5696202f39648c3451b018caf2a1219e
https://github.com/ntdiary/App/blob/ab815d218d81cd1ce5ccae8e6490b55cd7e6dd00/src/pages/home/ReportScreen.js#L205-L216 second way: https://github.com/ntdiary/App/commit/ab815d218d81cd1ce5ccae8e6490b55cd7e6dd00
@mananjadhav These maybe only help to understand the problem. 🙂
@AndrewGable, @mananjadhav, @bfitzexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!
Apologies for the delay @ntdiary. I understand the problem now, while still not able to reproduce.
I am more inclined towards showing a blank report page, when the transition is happening because it's very quick and I don't see a point of loading actions for a different report that isn't required. @AndrewGable Can you help me with the expected behaviour?
@ntdiary I've got some questions/feedback on the second proposal.
- We will have to convert
MainDrawerNavigatorfunction to class component. - We don't use
useEffecthooks related code. Please read the style guidelines here - I am trying to understand what does
allReportActionsstore.
function getPreviousReportActions() {
return allReportActions[previousReportID];
}
If the previous chat has 1K comments, are we storing all the comments in that? and I can see its an object, are we not cleaning it up? If I keep switching between multiple chats, will it store the actions/comments for all the previous navigated reportIds?
- Is
PREVIOUS_REPORTIDa string? or an object? We'reOnyx.merge(ONYXKEYS.PREVIOUS_REPORTID, String(reportID));merging but not setting? Any specific reason?
I am more inclined towards showing a blank report page
I also prefer this way. Because it makes less changes to the existing code, and is easier to optimize in the future.
We will have to convert MainDrawerNavigator function to class component. We don't use useEffect hooks related code. Please read the style guidelines here
I'm sorry, because I need to explain the problem in the code, so I wrote it out first. Next, i will follow the code specification
I am trying to understand what does allReportActions store.
allReportActions means all actions/comments of all users. Actually, I only want to take the previousReportAction related to the previousReportID here, but I haven't found a similar usage in other parts of the project. I need get the previousReportID with Onyx, and then need to get the related previousReportAction with Onyx again. maybe like this(nested onyx, I still don't know if it can be used):
let previousReportID;
let previousReportActions;
let previousConnectID;
Onyx.connect({
key: ONYXKEYS.PREVIOUS_REPORTID,
callback: (id) => {
if (previousConnectID) {
Onyx.disconnect(previousConnectID);
}
previousConnectID = Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${id}`,
callback: val => previousReportActions = val,
});
return previousReportID = id;
},
});
function getPreviousReportActions() {
return previousReportActions;
}
Is PREVIOUS_REPORTID a string? or an object?
It is a string, and no specific reason, just that I've seen similar usage, so I thought it was the recommended useage in this project: https://github.com/Expensify/App/blob/461f35620304c704b268d28a98fb547c00bab7a0/src/libs/actions/Report.js#L1201-L1206 @mananjadhav I can use Onyx.set according to the README.md in the react-native-onyx 🙂
allReportActions means all actions/comments of all users.
This piece is concerning.
@AndrewGable Do we know the expected behaviour here?