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 2021-12-13] [HOLD for payment 2021-12-06] Delete comment - Deleted comment is still visible on LHN #3293
Deleted comment shows as the recipient's email in the LHN. At first, the deleted comment still showed there, and then after a hard refresh, it just shows the email. Expected behavior is it would show the previous comment as though the deleted comment had never occurred.
There are 2 issues here (last message shown is not updated after deleting it and after reload it displays sender email) that need to be addressed separately, but I think a solution can be refactored into one new function partially.
Addressing the refresh issue
It is caused by the fact that function getSimplifiedReportObject, that is responsible for converting API data into object that is stored locally, gets last message by simply getting the last object value. This is not correct anymore because apparently a delete comment action just changes it's text to an empty string and it is still served by BE as an actual message.
The reason it displays an email is as simple as it being a fallback in case message is empty.
So my proposal here is to update the way lastReportAction is found here:
This will make sure last message has text (is not deleted).
Addressing the on delete issue
The root cause of this is the fact that data like lastMessageText, lastMessageTimestamp and lastActorEmail for a specific report are not updated on delete action. It is the way things work for updateReportActionMessage:
but deleteReportComment function is missing that code, so I would need to implement something similar there:
...
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,reportActionsToMerge);// If this is the most recent message, update the lastMessageif(reportAction.sequenceNumber===reportMaxSequenceNumbers[reportID]){
#TODO figureouthowtogetreportActionListhereconstreportActionList=[];constreportActionKey=_.find(Object.keys(reportActionList).reverse(),key=>_.last(reportActionList[key].message).text!=='',);constlastReportAction=reportActionList[reportActionKey];constcreateTimestamp=lastReportAction ? lastReportAction.created : 0;constlastMessageTimestamp=moment.utc(createTimestamp).unix();constlastMessageText=lodashGet(lastReportAction,['message','html'],'').replace(/((<br[^>]*>)+)/gi,' ').replace(/(<([^>]+)>)/gi,'');constlastActorEmail=lodashGet(lastReportAction,'accountEmail','');Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`,{
lastMessageText,
lastMessageTimestamp,
lastActorEmail,});}
...
Refactoring
I'm not exactly sure it would be worth it, but the code where I get last non-empty message text, timestamp and email can be refactored into a separate function getLastReportActionDetails(reportActionList) that would return an object with lastMessageText, lastMessageTimestamp and lastActorEmail. This function could be then used in both getSimplifiedReportObject and deleteReportComment.
Summary
I am yet to figure out how to get reportActionList in deleteReportComment function and I would also need to test if using sequence numbers to determine last message is good enough now that deleted messages can still have them, but otherwise that's it.
P.S. What does LHN stand for? It is referenced in the issue, but I couldn't find a relevant meaning online. Judging by the context I would assume it's synonymous with Last Chat Message, but I better be sure. Thanks.
letlastMessageText;if(report.reportActionCount>0){// We are removing any html tags from the message html since we cannot access the text version of any comments as// the report only has the raw reportActionList and not the processed version returned by Report_GetHistory// We convert the line-breaks in html to space ' ' before striping the tagslastMessageText=lastActionMessage.replace(/((<br[^>]*>)+)/gi,' ').replace(/(<([^>]+)>)/gi,'')||`[${translateLocal('common.deletedCommentMessage')}]`;}else{lastMessageText=null;}
This way if there are no report actions we default the LHN display to it's original behavior (showing email or phone).
Now when it comes to showing user's email if all the messages are deleted it gets more complicated. Since we don't have access to all reports in that function it would mean somehow fetching all the reports in an async manner, which as far as I am aware is something we are trying to avoid. This is especially the case for something that would run for each of your chats. I don't think this is feasible unless we get this info from BE, so I suggest just apply the fix above to remedy the obvious bug I have overseen in my original PR.
That looks good to me @dklymenk, I think it's fine to account for only the new chat scenario - if someone deletes all the chats in an existing message we can continue to show [Comment deleted]
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.16-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
changed the title [-]Delete comment - Deleted comment is still visible on LHN[/-][+][HOLD for payment 2021-12-06] Delete comment - Deleted comment is still visible on LHN[/+]on Nov 29, 2021
changed the title [-][HOLD for payment 2021-12-06] Delete comment - Deleted comment is still visible on LHN[/-][+][HOLD for payment 2021-12-13] [HOLD for payment 2021-12-06] Delete comment - Deleted comment is still visible on LHN[/+]on Dec 6, 2021
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.17-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
Activity
MelvinBot commentedon Jun 2, 2021
Triggered auto assignment to @cead22 (
Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.MelvinBot commentedon Jun 2, 2021
Triggered auto assignment to @jboniface (
External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.MelvinBot commentedon Jun 2, 2021
Triggered auto assignment to @NikkiWines (
Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.dklymenk commentedon Jun 3, 2021
There are 2 issues here (last message shown is not updated after deleting it and after reload it displays sender email) that need to be addressed separately, but I think a solution can be refactored into one new function partially.
Addressing the refresh issue
It is caused by the fact that function
getSimplifiedReportObject, that is responsible for converting API data into object that is stored locally, gets last message by simply getting the last object value. This is not correct anymore because apparently a delete comment action just changes it's text to an empty string and it is still served by BE as an actual message.The reason it displays an email is as simple as it being a fallback in case message is empty.
So my proposal here is to update the way
lastReportActionis found here:https://github.com/Expensify/Expensify.cash/blob/8b979de2cf00deafbba85c5c139f6d78cd1fd3f2/src/libs/actions/Report.js#L148-L153
with something like this:
This will make sure last message has text (is not deleted).
Addressing the on delete issue
The root cause of this is the fact that data like
lastMessageText,lastMessageTimestampandlastActorEmailfor a specific report are not updated on delete action. It is the way things work forupdateReportActionMessage:https://github.com/Expensify/Expensify.cash/blob/8b979de2cf00deafbba85c5c139f6d78cd1fd3f2/src/libs/actions/Report.js#L488-L493
and
updateReportWithNewAction:https://github.com/Expensify/Expensify.cash/blob/8b979de2cf00deafbba85c5c139f6d78cd1fd3f2/src/libs/actions/Report.js#L528-L534
but
deleteReportCommentfunction is missing that code, so I would need to implement something similar there:... Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, reportActionsToMerge); // If this is the most recent message, update the lastMessage if (reportAction.sequenceNumber === reportMaxSequenceNumbers[reportID]) { #TODO figure out how to get reportActionList here const reportActionList = []; const reportActionKey = _.find( Object.keys(reportActionList).reverse(), key => _.last(reportActionList[key].message).text !== '', ); const lastReportAction = reportActionList[reportActionKey]; const createTimestamp = lastReportAction ? lastReportAction.created : 0; const lastMessageTimestamp = moment.utc(createTimestamp).unix(); const lastMessageText = lodashGet(lastReportAction, ['message', 'html'], '') .replace(/((<br[^>]*>)+)/gi, ' ') .replace(/(<([^>]+)>)/gi, ''); const lastActorEmail = lodashGet(lastReportAction, 'accountEmail', ''); Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { lastMessageText, lastMessageTimestamp, lastActorEmail, }); } ...Refactoring
I'm not exactly sure it would be worth it, but the code where I get last non-empty message text, timestamp and email can be refactored into a separate function
getLastReportActionDetails(reportActionList)that would return an object withlastMessageText,lastMessageTimestampandlastActorEmail. This function could be then used in bothgetSimplifiedReportObjectanddeleteReportComment.Summary
I am yet to figure out how to get
reportActionListindeleteReportCommentfunction and I would also need to test if using sequence numbers to determine last message is good enough now that deleted messages can still have them, but otherwise that's it.P.S. What does LHN stand for? It is referenced in the issue, but I couldn't find a relevant meaning online. Judging by the context I would assume it's synonymous with Last Chat Message, but I better be sure. Thanks.
EDIT: Fix grammar
jboniface commentedon Jun 3, 2021
@dklymenk LHN = left hand navigation
48 remaining items
dklymenk commentedon Nov 23, 2021
Ok, so to fix the issue where it says "Comment deleted" when you create a new chat, I propose replacing
App/src/libs/actions/Report.js
Lines 173 to 178 in 10d8613
with
This way if there are no report actions we default the LHN display to it's original behavior (showing email or phone).
Now when it comes to showing user's email if all the messages are deleted it gets more complicated. Since we don't have access to all reports in that function it would mean somehow fetching all the reports in an async manner, which as far as I am aware is something we are trying to avoid. This is especially the case for something that would run for each of your chats. I don't think this is feasible unless we get this info from BE, so I suggest just apply the fix above to remedy the obvious bug I have overseen in my original PR.
Thanks.
NikkiWines commentedon Nov 23, 2021
That looks good to me @dklymenk, I think it's fine to account for only the new chat scenario - if someone deletes all the chats in an existing message we can continue to show
[Comment deleted]dklymenk commentedon Nov 24, 2021
I have submitted the fix #6458.
botify commentedon Nov 29, 2021
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.16-10 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 2021-12-06. 🎊
[-]Delete comment - Deleted comment is still visible on LHN[/-][+][HOLD for payment 2021-12-06] Delete comment - Deleted comment is still visible on LHN[/+][-][HOLD for payment 2021-12-06] Delete comment - Deleted comment is still visible on LHN[/-][+][HOLD for payment 2021-12-13] [HOLD for payment 2021-12-06] Delete comment - Deleted comment is still visible on LHN[/+]botify commentedon Dec 6, 2021
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.17-7 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 2021-12-13. 🎊
jboniface commentedon Dec 13, 2021
paid with bonus