You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-01-09] [$500] Web - Chat- A different group chat appears when refreshing the page #30868
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
changed the title [-]Web - Chat- A different group chat appears when refreshing the page[/-][+][$500] Web - Chat- A different group chat appears when refreshing the page[/+]on Nov 3, 2023
Please re-state the problem that we are trying to solve in this issue.
A different group chat is opened when we refresh while we have opened profile detail of group chat member
What is the root cause of that problem?
When we open profile detail of a member of a group chat the route is changed to '.../a/memberID or ParticipantID' so the report id is lost from the url, hence when we refresh the last group chat reportId will be populated to ReportScreen via ReportIDSetter in the below code
which sets the reportID to the id returned from ReportUtils.findLastAccessedReport which does not reliably return the id of last opened report by the user.
What changes do you think we should make in order to solve the problem?
We need to save a stack of latest opened report ids the user opened in onyx everytime a user opens a report. Then we will populate the latest available report id from the stack in the ReportScreenIDSetter changing this line of code
const lastOpendAvailableID = _.find(lastOpenedReportIDs, (reportID) => _.find(reports, (report) => report.reportID === reportID));
// If there is no reportID in route, try to find last accessed and use it for setParams
const reportID =
lastOpendAvailableID || getLastAccessedReportID(reports, !canUseDefaultRooms, policies, isFirstTimeNewExpensifyUser, lodashGet(route, 'params.openOnAdminRoom', false));
after passing lastOpenedReportIDs prop via withOnyx here
So we will only fallback to the existing ReportUtils.findLastAccessedReport logic/code only in case when there is no available report id value saved in that new key ('LAST_OPENED_REPORT_IDS') we will create in onyx.
We can update the 'LAST_OPENED_REPORT_IDS' value on onyx in a useEffect on ReportScreen that runs when there is a change in reportID and save up to say 10 recent opened ids which will serve us to be a back up in case last opened report id doesn't exist or got deleted.
useEffect(() => {
if (!_.isEmpty(reportID)) {
const updatedLastOpenedIDs = _.clone(lastOpenedReportIDs || []);
// to limit the no of ids saved to 10
if (updatedLastOpenedIDs.length === 10) updatedLastOpenedIDs.pop();
updatedLastOpenedIDs.unshift(reportID);
Onyx.merge(ONYXKEYS.LAST_OPENED_REPORT_IDS, updatedLastOpenedIDs);
}
}, [reportID]);
Moreover, we need to clear that value on onyx on signout so that a report ids saved for one user will not be used for another.
POC:
2023-11-03.23-07-08.mp4
What alternative solutions did you explore? (Optional)
or we can alternatively update the value in onyx every time the user navigates to a report.
Please re-state the problem that we are trying to solve in this issue.
A different report is opened when we refresh while we have opened profile detail of group chat member
What is the root cause of that problem?
the profile page route doesnt contain any info about the reportId therefore the opened report in the background is not the same
What changes do you think we should make in order to solve the problem?
we need to modify the url of the profile page to contain the url of the report:
for example:
this way the screenwrapper will get the reportid and then displays it /r/reportId/participants/:id/profile/
or we can add reportId as a param and modify the screener to look for this param and open it in the background
that will sort the reports by "lastReadTime". This is incorrect because the "lastReadTime" refers to the latest time the user read a new message, not the latest time the user visits a report. For example, if we read a new message A on 3/10/2023, and re-visit its report on 4/10/2023, the "lastReadTime" is still '3/10/2023'.
What changes do you think we should make in order to solve the problem?
Once we visit the report, we need to add the lastVisitTime: DateUtils.getDBTime() to the report or use ONYXKEYS.COLLECTION.REPORT_METADATA to store the above data.
Then, in the sortReportsByLastRead, using lastVisitTime to sort the reports. We can do it by updating:
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.20-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-01-09. 🎊
After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
External issue reporter
Contributor that fixed the issue
Contributor+ that helped on the issue and/or PR
For reference, here are some details about the assignees on this issue:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@shubham1206agra] The PR that introduced the bug has been identified. Link to the PR:
[@shubham1206agra] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@shubham1206agra] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
[@shubham1206agra] Determine if we should create a regression test for this bug.
[@shubham1206agra] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@abekkala / @lschurr] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@shubham1206agra] The PR that introduced the bug has been identified. Link to the PR: None as this is new functionality
[@shubham1206agra] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: NA
[@shubham1206agra] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: Not required
[@shubham1206agra] Determine if we should create a regression test for this bug. Yes
[@shubham1206agra] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
Navigate to a group conversation
Clicking on a profile
Refresh the page. Verify the background report opened is same as group conversation opened in step 1.
[@abekkala / @lschurr] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
@shubham1206agra I think we may need to get a bit more crisp on your regression test
Navigate to a group conversation
Clicking on a profile
Refresh the page. Check the background report opened.
Based on the OP
Action Performed:
Create a group conversation
Type something
Clicking on a profile
Refresh the page
Expected Result:
The same group chat appears when refreshing the page
in your regression would we need to type and/or send a message prior to clicking on a profile. After refreshing the page the last step should be "verifying" the correct result. Meaning, should it be "Verify the group chat still appears" rather than the issue of a different group chat appearing after refreshing the page
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
[-]Web - Chat- A different group chat appears when refreshing the page[/-][+][$500] Web - Chat- A different group chat appears when refreshing the page[/+]melvin-bot commentedon Nov 3, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01b7f90c720aa62a3c
melvin-bot commentedon Nov 3, 2023
Triggered auto assignment to @abekkala (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 3, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (
External)melvin-bot commentedon Nov 3, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)FitseTLT commentedon Nov 3, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
A different group chat is opened when we refresh while we have opened profile detail of group chat member
What is the root cause of that problem?
When we open profile detail of a member of a group chat the route is changed to '.../a/memberID or ParticipantID' so the report id is lost from the url, hence when we refresh the last group chat reportId will be populated to ReportScreen via ReportIDSetter in the below code
App/src/libs/Navigation/AppNavigator/ReportScreenIDSetter.js
Lines 85 to 87 in 7b546b0
which sets the reportID to the id returned from
ReportUtils.findLastAccessedReportwhich does not reliably return the id of last opened report by the user.What changes do you think we should make in order to solve the problem?
We need to save a stack of latest opened report ids the user opened in onyx everytime a user opens a report. Then we will populate the latest available report id from the stack in the
ReportScreenIDSetterchanging this line of codeApp/src/libs/Navigation/AppNavigator/ReportScreenIDSetter.js
Lines 85 to 87 in 7b546b0
to
after passing lastOpenedReportIDs prop via
withOnyxhereSo we will only fallback to the existing
ReportUtils.findLastAccessedReportlogic/code only in case when there is no available report id value saved in that new key ('LAST_OPENED_REPORT_IDS') we will create in onyx.We can update the 'LAST_OPENED_REPORT_IDS' value on onyx in a
useEffecton ReportScreen that runs when there is a change inreportIDand save up to say 10 recent opened ids which will serve us to be a back up in case last opened report id doesn't exist or got deleted.Moreover, we need to clear that value on onyx on signout so that a report ids saved for one user will not be used for another.
POC:
2023-11-03.23-07-08.mp4
What alternative solutions did you explore? (Optional)
or we can alternatively update the value in onyx every time the user navigates to a report.
abzokhattab commentedon Nov 3, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
A different report is opened when we refresh while we have opened profile detail of group chat member
What is the root cause of that problem?
the profile page route doesnt contain any info about the reportId therefore the opened report in the background is not the same
What changes do you think we should make in order to solve the problem?
we need to modify the url of the profile page to contain the url of the report:
for example:
this way the screenwrapper will get the reportid and then displays it
/r/reportId/participants/:id/profile/or we can add
reportIdas a param and modify the screener to look for this param and open it in the backgroundDylanDylann commentedon Nov 4, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
getLastAccessedReportIDto get the report to display.App/src/libs/Navigation/AppNavigator/ReportScreenIDSetter.js
Lines 63 to 72 in 7bd51eb
findLastAccessedReportis not working properly.App/src/libs/ReportUtils.js
Lines 575 to 581 in 7bd51eb
findLastAccessedReportusessortReportsByLastRead:App/src/libs/ReportUtils.js
Lines 263 to 269 in 7bd51eb
What changes do you think we should make in order to solve the problem?
Once we visit the report, we need to add the
lastVisitTime: DateUtils.getDBTime()to the report or useONYXKEYS.COLLECTION.REPORT_METADATAto store the above data.Then, in the
sortReportsByLastRead, usinglastVisitTimeto sort the reports. We can do it by updating:App/src/libs/ReportUtils.js
Lines 263 to 269 in 7bd51eb
to:
function sortReportsByLastRead(reports) { return _.chain(reports) + .map((report) => { + const lastReadTime = lodashGet(report, 'lastVisitTime') || lodashGet(report, 'lastReadTime'); + return {...report, lastReadTime}; }) .toArray() .filter((report) => report && report.reportID && report.lastReadTime) .sortBy('lastReadTime') .value(); }What alternative solutions did you explore? (Optional)
59 remaining items
melvin-bot commentedon Jan 2, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jan 2, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.20-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-01-09. 🎊
After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jan 2, 2024
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
lschurr commentedon Jan 2, 2024
Leaving this with you @abekkala since I think you'll be back for the payout date!
shubham1206agra commentedon Jan 3, 2024
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
abekkala commentedon Jan 9, 2024
@shubham1206agra I think we may need to get a bit more crisp on your regression test
Based on the OP
Action Performed:
Expected Result:
The same group chat appears when refreshing the page
in your regression would we need to type and/or send a message prior to clicking on a profile. After refreshing the page the last step should be "verifying" the correct result. Meaning, should it be "Verify the group chat still appears" rather than the issue of a different group chat appearing after refreshing the page
shubham1206agra commentedon Jan 10, 2024
@abekkala Updated the test.
abekkala commentedon Jan 11, 2024
abekkala commentedon Jan 11, 2024
@shubham1206agra payment sent and contract ended - thank you! 🎉
abekkala commentedon Jan 11, 2024
@DylanDylann payment sent and contract ended - thank you! 🎉