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

New Thread Report Empty State, Header, LHN, OpenReport, Buttons for DEV #18522

Merged
merged 71 commits into from
May 12, 2023

Conversation

grgia
Copy link
Contributor

@grgia grgia commented May 6, 2023

Details

Add the FE associated with creating and displaying thread reports.

This includes:
Appearance in LHN
image

Thread Headers
image
image

Reply in Thread Button in Context Menus
image
image

Thread Report Empty State
No replies:
image
With Replies:
image

Threads appearing in Search Bar
image

Deleting a Parent Message
image

Fixed Issues

$ #18755 - Report Headers
#18759 - Opening a Report (accessible in DEV only)
#18758 - Adding the button (accessible in DEV only)

Tests

  • Verify that no errors appear in the JS console

  • In a DM chat, hover on a chat and click the reply in thread button. Ensure a new thread is created.

  • In a DM chat, right-click on a chat and click the reply in thread button in the pop-up menu. Ensure a new thread is created.

  • Visually QA the created thread report to ensure that the LHN, Header, and Empty State display the correct information.

    • The title of the Header/LHN will be the parent message
    • The subtitle of the LHN will be 'No Activity Yet' if no replies, or display the latest reply.
  • In a Workspace chat, create a thread.

  • Visually QA the created thread report to ensure that the LHN, Header, and Empty State display the correct information.

    • The title of the Header/LHN will be the parent message
    • The subtitle of the LHN will be <Workspace Name>
  • In a Workspace Room chat, create a thread.

  • Visually QA the created thread report to ensure that the LHN, Header, and Empty State display the correct information.

    • The title of the Header/LHN will be the parent message
    • The subtitle of the LHN will be <Workspace Name> • #<roomName>
  • Go to a chat that you've already created a thread for and replied to. Click reply in the thread. Ensure that the existing report opens with your existing reply (and not a new one).

  • Send a message. Now create a thread from that message. Then go back to the original message in the parent report and delete it. Ensure it shows in BOTH parent report and child report as [Deleted Message]

Offline tests

QA Steps

  • 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
    • 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 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
Mobile Web - Chrome image
Mobile Web - Safari
Desktop image
iOS image image image
Android image image image

@grgia grgia self-assigned this May 6, 2023
src/pages/home/ReportScreen.js Outdated Show resolved Hide resolved
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
@OSBotify
Copy link
Contributor

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

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.3.14-14 🚀

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

@jasperhuangg
Copy link
Contributor

Hey @chiragsalian @grgia was doing some testing and found that the "Reply in Thread" button has some unexpected behavior on mobile web. It takes you to the LHN and not the thread report. Wanna tackle this in a follow-up?

Screen.Recording.2023-05-19.at.2.08.18.PM.mov

// Add the createdReportActionID parameter to the API call
params.createdReportActionID = optimisticCreatedAction.reportActionID;
// Add a created action, unless we are creating a thread
if (parentReportActionID === '0') {
Copy link
Contributor

Choose a reason for hiding this comment

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

@stitesExpensify Can you please explain why we don't create the CREATED report action for threads? A thread is also a new report. We think this is causing a bug #19490.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that you're right and we should always do this. It looks like the back end is creating a CREATED action, so we should do it optimistically too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

Comment on lines +84 to +85
// If the item is a thread within a workspace, we will show the subtitle as the second line instead of in a pill
const alternativeText = optionItem.isThread && optionItem.subtitle ? optionItem.subtitle : optionItem.alternateText;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intentional to show workspace name and room name in thread?
As there's no way to see last thread message in LHN, the issue was reported here - #19447.
This only works in DM chat as subtitle not exist.

So I'd like to confirm if it's fine to use optionItem.alternateText here no matter thread or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

@grgia bump ^

Here's design doc:

LHN:

2023-06-02_11-08-58

Header:

2023-06-02_11-09-07

if (isThread(report)) {
const parentReportAction = ReportActionsUtils.getParentReportAction(report);
const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' ');
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage');
Copy link
Member

Choose a reason for hiding this comment

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

When the action is an Attachment, the title of the report will be Attachment. But this will be translated so we need to handle that ourselves which is being done in #19517.

/>
)}
</View>
<View style={[styles.threadDividerLine]} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #19443

The divider line overlaps with an unread mark, so we should only show the divider line if the first comment in the thread is not marked as unread.

@s77rt
Copy link
Contributor

s77rt commented Jun 15, 2023

Not a regression but a bug: After adding thread reports we had to revisit the implementation of attachment carousel since it's implemented to only cycle through the report actions without including the report parent action which caused a crash #20214.

onPress: (closePopover, {reportAction, reportID}) => {
Report.navigateToAndOpenChildReport(lodashGet(reportAction, 'childReportID', '0'), reportAction, reportID);
if (closePopover) {
hideContextMenu(true, ReportActionComposeFocusManager.focus);
Copy link
Member

Choose a reason for hiding this comment

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

Having the delay param set to true causes #19776.

@parasharrajat
Copy link
Member

We missed listening to thread parent changes on LHN which prevented LHN update when thread parent is changed.
#23424

@@ -96,6 +96,10 @@ const ReportActionItemFragment = (props) => {
}
const {html, text} = props.fragment;

if (props.fragment.isDeletedParentAction) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines introduced a regression, as in ReportActionItem.js we added a margin based on the report action's isAttachment property.

@sobitneupane
Copy link
Contributor

This case was missed while making the changes here.

Issue: Inconsistency: Different grayness levels on parent and child message

Reproduction Steps:

  1. Be Offline
  2. Go to any chat
  3. Send a message
  4. Go reply in thread
  5. Send a reply and notice the level of grayness on the Parent and child message

displayAsGroup={false}
isMostRecentIOUReportAction={false}
shouldDisplayNewMarker={false}
index={0}
Copy link
Contributor

Choose a reason for hiding this comment

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

This didn't consider parent report action index in thread.
More details about the root cause: #30805 (comment)

*/
function navigateToAndOpenChildReport(childReportID = '0', parentReportAction = {}, parentReportID = '0') {
if (childReportID !== '0') {
openReport(childReportID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #43120, this line causes OpenReport API called twice when opening an existing thread.

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

Successfully merging this pull request may close these issues.