Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deleted message] in LHN subtitle #28364

Merged
merged 12 commits into from
Oct 17, 2023

Conversation

rojiphil
Copy link
Contributor

@rojiphil rojiphil commented Sep 28, 2023

@rushatgabhane @chiragsalian

Details

This PR makes the following changes to the code:
A) Code changes in shouldReportActionBeVisibleAsLastAction function so that an action is not considered to be visible if the message text is empty and it is, also, not a deleted parent action with visible child actions. This will ensure that getLastVisibleAction will also include deleted parent actions with visible child actions for display.
B) Implemented a getDeletedParentActionMessageForChatReport utility function in ReportUtils to return [Deleted task] for canceled tasks and [Deleted message] for all other actions with deleted parent action.
C) Implemented a getLastVisibleMessage utility function in ReportUtils to return appropriate deleted message using getDeletedParentActionMessageForChatReport. The utility function of getLastVisibleMessage in ReportActionsUtils was not directly used to avoid lint errors. The newly implemented utility function in ReporUtils also reuses the getLastVisibleMessage from ReportActionsUtils to avoid duplicate code.
D) Code changes in getLastMessageTextForReport so that appropriate deleted message using getDeletedParentActionMessageForChatReport can be displayed in LHN.
E) Finally, in deleteReportComment, we call the new utility function from ReportUtils instead of ReportActionsUtils

Fixed Issues

$ #19722
PROPOSAL: #19722 (comment)

Tests

Test for [Deleted message]

  1. Send message Parent in a Chat Report
  2. Reply in thread for the message Parent
  3. Send a child message ‘Child’ in the thread with parent message Parent
  4. Delete the parent message Parent in thread.
  5. Observe the LHN subtitle for Chat Report.
    Expected Behaviour: Verify [Deleted message] as LHN subtitle for Chat Report.

Test for [Deleted task]

  1. Assign task (say Buy Grocery) in a Chat Report
  2. Leave a task message (say Milk 1L) in the task report
  3. Cancel task using 3dots menu in task report.
  4. Observe the LHN subtitle for Chat Report.
    Expected Behaviour: Verify [Deleted task] as LHN subtitle for Chat Report.
  • Verify that no errors appear in the JS console

Offline tests

Same as Steps for Tests Section.

QA Steps

Same as Steps for Tests Section.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • 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)
    • 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).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • 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)
  • I followed proper code patterns (see Reviewing the code)
    • 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. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • 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.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • 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:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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 Copy label for a copy review on the original GH to get the correct copy.
    • 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.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • 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 using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • 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
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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
  • If any new file was added I verified that:
    • 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
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • 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.
  • 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 Avatar is modified, I verified that Avatar is working as expected in all cases)
  • 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.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
19722-web-safari-1.mp4
Mobile Web - Chrome
19722-mweb-chrome-1.mp4
Mobile Web - Safari
19722-mweb-safari-1.mp4
Desktop
19722-desktop-1.mp4
iOS
19722-ios-native-1.mp4
Android
19722-android-native-1.mp4
Offline
19722-offline-1.mp4

@rojiphil rojiphil requested a review from a team as a code owner September 28, 2023 04:43
@melvin-bot melvin-bot bot requested review from rushatgabhane and removed request for a team September 28, 2023 04:43
@melvin-bot
Copy link

melvin-bot bot commented Sep 28, 2023

@rushatgabhane 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]

@rojiphil

This comment was marked as outdated.

@rojiphil
Copy link
Contributor Author

@rushatgabhane

Another thing to note is that lint code check is failing. The reason is that it is already broken in main as I see the same failure with or without our changes. Just wanted to mention this for reference. Also, not sure if we have to take any action for this.

@rojiphil
Copy link
Contributor Author

@rushatgabhane Gentle bump on review here

@rushatgabhane
Copy link
Member

Another thing to note is that lint code check is failing. The reason is that it is already broken in main as I see the same failure with or without our changes. Just wanted to mention this for referenc

alright, thanks!

@rojiphil
Copy link
Contributor Author

Another thing to note is that lint code check is failing. The reason is that it is already broken in main as I see the same failure with or without our changes. Just wanted to mention this for referenc

alright, thanks!

@rushatgabhane
Sorry. Lint code check failure was my mistake as I had introduced lint errors.
I have fixed this and have also tested across platforms.
Can you please review the PR?

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 3, 2023

@rushatgabhane Gentle nudge on reviewing this PR.

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug:

  1. create a task
  2. reply in thread - "child"
  3. create another thread for "child" - "child2"
  4. send a message in child2 and delete child

Expected: LHN should show task title
Actual: LHN show Deleted Message

image

@rushatgabhane
Copy link
Member

rushatgabhane commented Oct 3, 2023

@rojiphil also, are you getting an infinite loop on creating a new thread? I merged with latest main so im unsure

Screen.Recording.2023-10-03.at.10.27.11.mov

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 3, 2023

Sorry. Was away from my laptop and test setup. Will check and get back on this.

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 3, 2023

@rojiphil also, are you getting an infinite loop on creating a new thread? I merged with latest main so im unsure

Screen.Recording.2023-10-03.at.10.27.11.mov

@rushatgabhane I just merged the PR branch with latest main. Also, I tested a normal flow. It seems to be working fine for me. I do not get infinite loop or console errors.
Looks like the latest main does not have that problem.
Please check and see if you still get the problem.
Attached is a test version for your reference.

19722-regular-test.mp4

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 3, 2023

Bug:

  1. create a task
  2. reply in thread - "child"
  3. create another thread for "child" - "child2"
  4. send a message in child2 and delete child

Expected: LHN should show task title
Actual: LHN show Deleted Message

@rushatgabhane
I tested the same steps. But, to me, LHN does show the task title. It does not show Deleted message.
Attaching the video for this too.
Please check and let me know if I misunderstood any of the reproduction steps.

19722-del-msg-task.mp4

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 3, 2023

@rushatgabhane
Have merged again as there were some conflicts.
Also, have tested with the same results.
Please review my comments here and here

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 4, 2023

@rushatgabhane
Gentle bump on review.
Is it possible for us to work together when we are both available on this so that we can take this to closure soon?
I can make myself available at a time of your convenience. Please let me know.

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 4, 2023

@rushatgabhane
Have merged again due to conflicts with the main. There are greater chances of merge conflicts here as we are making changes to a highly used code. So, it would be good if we could close on this soon. Need your support on this.

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 5, 2023

@rushatgabhane
I again tried to reproduce this but could not. I may be missing something simple here. I have tried to follow your steps and have attached a video here.
Further, I also tried many different combinations but could not reproduce the problem.
Can you help me with more details to reproduce this?

Or is this resolved in the latest main?
Need your support in taking this forward.

@rojiphil
Copy link
Contributor Author

Further, I also tried many different combinations but could not reproduce the problem

i can't reproduce it either

@rushatgabhane

Oh! I was really hoping that you could reproduce this because the screenshot here is still bothering me.
Let me spend some more time on this today as there must be some explanation for this.

@chiragsalian

Please hold your review for the time being.

@rojiphil
Copy link
Contributor Author

Oh! I was really hoping that you could reproduce this because the screenshot here is still bothering me.
Let me spend some more time on this today as there must be some explanation for this.

@rushatgabhane

Even after giving a fresh look, I am still not able to reproduce this. So, either this is an extreme edge case or the latest main has fixed this. To me, it looks like the latter case.

The only logical explanation for this to happen is if, somehow, the isDeletedParentAction flag was set for Task Preview action. However, this can only happen for canceled tasks. But, in that case, the message for Task Preview would also change to [Deleted task] which is not observed in the screenshot. Don’t know if this information helps you recollect any specific steps you took to reproduce this. Otherwise, thinking of moving on.

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 13, 2023

@rushatgabhane @chiragsalian

I wanted to discuss one more point. Currently, as seen in the attached video, LHN shows previous visible message for canceled task having visible child actions. However, since isDeletedParentAction flag is set for canceled tasks, the message [Deleted message] gets displayed in LHN with our fix here. We can prevent this with an additional check of isCreatedTaskReportAction for the last visible action. However, I think, showing [Deleted task] in LHN for canceled tasks is a fix we need here. Or, even, do nothing is an option here.
So, we have the following options:
A) Ignore canceled tasks using an additional check of isCreatedTaskReportAction or
B) Implement a fix for showing [Deleted task] in LHN in this issue itself or
C) Raise a separate issue and PR for (B).
D) Do Nothing
What are your thoughts?

19722-deleted-task-lhn.mp4

@rojiphil
Copy link
Contributor Author

@rushatgabhane @chiragsalian

Curious to know which option makes sense for this comment here.
If Do Nothing is fine, we are ready to merge.

@rojiphil
Copy link
Contributor Author

rojiphil commented Oct 16, 2023

@thienlnam

Coming from your comment here and this comment here in this issue, curious to know your thoughts on what should get displayed in LHN subtitle for a chat report that has the canceled task report’s action as the last visible action (note: here, the canceled task still has visible comments).
To me, it looks like [Deleted task] can be displayed just like how we show [Deleted message] for deleted thread messages (refer attached image).
What do you think?
Screenshot 2023-10-16 at 10 05 54 AM

@thienlnam
Copy link
Contributor

Yeah I agree, let's go with the [Deleted task] direction

@chiragsalian
Copy link
Contributor

Curious to know which option makes sense for #28364 (comment).

I am okay with option B or C. Personally i think B would move ahead faster but I'm okay with either 🙂 let us know what you prefer. It would not require any backend changes right?

@rojiphil
Copy link
Contributor Author

Yeah I agree, let's go with the [Deleted task] direction

Thanks @thienlnam for helping us move ahead on this.

@rojiphil
Copy link
Contributor Author

I am okay with option B or C. Personally i think B would move ahead faster but I'm okay with either 🙂 let us know what you prefer. It would not require any backend changes right?

@chiragsalian
Thanks for bringing clarity on the options. We do not need any backend changes here.
Also, I agree with you that doing B here will help us move faster.
I will make the necessary changes and get it reviewed again.

@chiragsalian
Copy link
Contributor

Awesome, thanks for staying on top of this @rojiphil 🙂

@rojiphil
Copy link
Contributor Author

@rushatgabhane

This PR, now, also includes a fix for [Deleted task] as discussed in previous comments.
The PR description and test steps are also updated.
Also, I have tested and it works well too.
Over to you for review.

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@chiragsalian chiragsalian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chiragsalian chiragsalian merged commit b22fbba into Expensify:main Oct 17, 2023
17 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/chiragsalian in version: 1.3.86-0 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 1.3.86-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@tienifr
Copy link
Contributor

tienifr commented Oct 20, 2023

Coming from #28002, I found out the following bug: cc @situchan

Screen.Recording.2023-10-20.at.15.12.28.mp4

@rojiphil
Copy link
Contributor Author

Coming from #28002, I found out the following bug:

Nice catch. This problem occurs when the last visible action is a message that has been moderated as pending removal.

@chiragsalian @rushatgabhane
The code here handles the case where the last visible action is a message that has been moderated as pending remove. This case is not handled yet. However, this code is a bit ugly (as already mentioned in the comment) as it directly accesses the message object without using a utility function for retrieving the last visible message (like getLastVisibleMessage). Please advise on how to proceed on this. We can create a PR to fix this.

@chiragsalian
Copy link
Contributor

Please advise on how to proceed on this.

I think its best to make another GH issue, i.e., report it as a bug. We'll mark it external and receive proposals to review and implement the one that sounds like it would work the best. Off the top of my head i can't think of a good solution without playing around with it a bit.

@rojiphil
Copy link
Contributor Author

@chiragsalian @rushatgabhane

Also found out another case related to [Attachment].
I think, the solution is straightforward here. So, I have raised a PR for this here and will request for review soon.

Problem:
When an attachment is the immediately previous message to a cancelled task that has visible actions, the LHN subtitle (alternate text) of the chat report shows [Attachment] instead of [Deleted task] when the latest visible action is a canceled task with visible actions. Same thing applies for deleted message.

Steps:

  1. Add an attachment to a chat report
  2. Add a task to chat report
  3. In task report, add a task message
  4. Click on 3dots menu and cancel the task
    Actual Behaviour: LHN subtitle for chat report displays [Attachment]
    Expected Behaviour: LHN subtitle for chat report should display [Deleted task]
new-issue-del-task-att.mp4

Root Cause:
In the scenario of canceled task/deleted message with visible actions, BE will set the lastMessage*** variables in Report to reflect the attachment. Now, when the LHN subtitle text is determined using getLastMessageTextForReport as shown here, the isReportMessageAttachment here will return true due to lastMessageText and lastMessageHtml pointing to the attachment. Thus, the [Attachment] value is set as LHN subtitle instead of [Canceled task]/[Deleted message]

Changes:
To resolve this problem, we can perform the check of isReportMessageAttachment after the check of isDeletedParentAction like this here:

  if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) {
    lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml, translationKey: report.lastMessageTranslationKey})) {
    lastMessageTextFromReport = `[${Localize.translateLocal(report.lastMessageTranslationKey || 'common.attachment')}]`;
}

@rojiphil
Copy link
Contributor Author

I think its best to make another GH issue, i.e., report it as a bug. We'll mark it external and receive proposals to review and implement the one that sounds like it would work the best.

For reference, the bug is reported in Slack here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants