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

[HOLD for payment 2023-11-27] [$1000] Web - Chat - The display name goes down when deleting an attachment in main thread #25415

Closed
1 of 6 tasks
izarutskaya opened this issue Aug 17, 2023 · 58 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering Internal Requires API changes or must be handled by Expensify staff

Comments

@izarutskaya
Copy link

izarutskaya commented Aug 17, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open the website
  2. Open any chat from LHN
  3. send a pdf as an attachment
  4. create a reply in the thread for the attachment
  5. send a text in the thread
  6. click the header in the thread and back to the main chat room
  7. delete the pdf file
  8. observe the display name

Expected Result:

The display name should be in a fixed position

Actual Result:

The display name goes down

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: v1.3.55-1

Reproducible in staging?: Y

Reproducible in production?: N

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Screenshare.-.2023-08-17.5_07_18.PM.mp4
Recording.1249.mp4

Expensify/Expensify Issue URL:

Issue reported by: @misgana96

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692281066076859

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015df75499581661dc
  • Upwork Job ID: 1693715531299635200
  • Last Price Increase: 2023-08-21
  • Automatic offers:
    • cubuspl42 | Contributor | 26249100
    • misgana96 | Reporter | 26249103
@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

Triggered auto assignment to @sophiepintoraetz (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@OSBotify
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

Triggered auto assignment to @yuwenmemon (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@sophiepintoraetz
Copy link
Contributor

sophiepintoraetz commented Aug 17, 2023

Going to see if I can replicate this shortly but reviewing the information, I'm not sure its deploy-blocker worthy?

@yuwenmemon
Copy link
Contributor

Yes, defintely not deploy blocker worthy.

@yuwenmemon yuwenmemon removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Aug 17, 2023
@yuwenmemon
Copy link
Contributor

This can be external as well @sophiepintoraetz - feel free to add at your leisure.

@Pujan92
Copy link
Contributor

Pujan92 commented Aug 17, 2023

I think regression from this PR as immediate we may not removing the space.

@bernhardoj
Copy link
Contributor

Yes, it is a regression of my PR.

@cubuspl42 looks like we missed this case. When we delete the attachment, previousMessage is still there until the request is completed, so isAttachment is still true even when [Deleted message] is shown.

We have a special case here to immediately show the [Deleted message] before the delete request is completed.

// Threaded messages display "[Deleted message]" instead of being hidden altogether.
// While offline we display the previous message with a strikethrough style. Once online we want to
// immediately display "[Deleted message]" while the delete action is pending.
if ((!props.network.isOffline && props.hasCommentThread && props.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) || props.fragment.isDeletedParentAction) {
return <RenderHTML html={`<comment>${props.translate('parentReportAction.deletedMessage')}</comment>`} />;
}

I'm thinking that we can move that condition above to ReportActionItemMessage.

view code to understand better
diff --git a/src/pages/home/report/ReportActionItemFragment.js b/src/pages/home/report/ReportActionItemFragment.js
index 009c111840..d19ae5abbe 100644
--- a/src/pages/home/report/ReportActionItemFragment.js
+++ b/src/pages/home/report/ReportActionItemFragment.js
@@ -105,14 +105,6 @@ function ReportActionItemFragment(props) {
             }
             const {html, text} = props.fragment;
 
-            // Threaded messages display "[Deleted message]" instead of being hidden altogether.
-            // While offline we display the previous message with a strikethrough style. Once online we want to
-            // immediately display "[Deleted message]" while the delete action is pending.
-
-            if ((!props.network.isOffline && props.hasCommentThread && props.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) || props.fragment.isDeletedParentAction) {
-                return <RenderHTML html={`<comment>${props.translate('parentReportAction.deletedMessage')}</comment>`} />;
-            }
-
             // If the only difference between fragment.text and fragment.html is <br /> tags
             // we render it as text, not as html.
             // This is done to render emojis with line breaks between them as text.
diff --git a/src/pages/home/report/ReportActionItemMessage.js b/src/pages/home/report/ReportActionItemMessage.js
index 7dcb2b51db..6f32cf4496 100644
--- a/src/pages/home/report/ReportActionItemMessage.js
+++ b/src/pages/home/report/ReportActionItemMessage.js
@@ -3,12 +3,15 @@ import {View, Text} from 'react-native';
 import PropTypes from 'prop-types';
 import _ from 'underscore';
 import lodashGet from 'lodash/get';
+import CONST from '../../../CONST';
 import styles from '../../../styles/styles';
 import ReportActionItemFragment from './ReportActionItemFragment';
 import * as ReportUtils from '../../../libs/ReportUtils';
 import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
 import reportActionPropTypes from './reportActionPropTypes';
 import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
+import useNetwork from '../../../hooks/useNetwork';
+import RenderHTML from '../../../components/RenderHTML';
 
 const propTypes = {
     /** The report action */
@@ -33,25 +36,35 @@ const defaultProps = {
 };
 
 function ReportActionItemMessage(props) {
+    const {isOffline} = useNetwork();
+    const hasCommentThread = ReportActionsUtils.hasCommentThread(props.action);
     const messages = _.compact(props.action.previousMessage || props.action.message);
     const isAttachment = ReportUtils.isReportMessageAttachment(_.last(messages));
     return (
-        <View style={[styles.chatItemMessage, !props.displayAsGroup && isAttachment ? styles.mt2 : {}, ...props.style]}>
+        <View style={[styles.chatItemMessage, ...props.style]}>
             {!props.isHidden ? (
-                _.map(messages, (fragment, index) => (
-                    <ReportActionItemFragment
-                        key={`actionFragment-${props.action.reportActionID}-${index}`}
-                        fragment={fragment}
-                        isAttachment={props.action.isAttachment}
-                        hasCommentThread={ReportActionsUtils.hasCommentThread(props.action)}
-                        attachmentInfo={props.action.attachmentInfo}
-                        pendingAction={props.action.pendingAction}
-                        source={lodashGet(props.action, 'originalMessage.source')}
-                        accountID={props.action.actorAccountID}
-                        loading={props.action.isLoading}
-                        style={props.style}
-                    />
-                ))
+                _.map(messages, (fragment, index) =>
+                    // Threaded messages display "[Deleted message]" instead of being hidden altogether.
+                    // While offline we display the previous message with a strikethrough style. Once online we want to
+                    // immediately display "[Deleted message]" while the delete action is pending.
+                    (!isOffline && hasCommentThread && props.action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) || fragment.isDeletedParentAction ? (
+                        <RenderHTML html={`<comment>${props.translate('parentReportAction.deletedMessage')}</comment>`} />
+                    ) : (
+.                       // we need to move the margin style here so the flaggedContent text does not get affected with the style (this exist before too)
+                        <View style={!props.displayAsGroup && isAttachment ? styles.mt2 : {}}>
+                            <ReportActionItemFragment
+                                key={`actionFragment-${props.action.reportActionID}-${index}`}
+                                fragment={fragment}
+                                isAttachment={props.action.isAttachment}
+                                attachmentInfo={props.action.attachmentInfo}
+                                pendingAction={props.action.pendingAction}
+                                source={lodashGet(props.action, 'originalMessage.source')}
+                                accountID={props.action.actorAccountID}
+                                loading={props.action.isLoading}
+                                style={props.style}
+                            />
+                        </View>
+                    ),
+                )
             ) : (
                 <Text style={[styles.textLabelSupporting, styles.lh20]}>{props.translate('moderation.flaggedContent')}</Text>
             )}

Let me know what you think!

@getusha
Copy link
Contributor

getusha commented Aug 18, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

There is a margin after deleting an attachment.

What is the root cause of that problem?

This is a regression from #24539
The external margin is only need for attachments that are not displayed as a group (for attachments that are the first message with avatar and name). Since the margin is applied to a component that renders every type of comment, it will also be applied to the [Deleted message] and then removed right away after the conditions are met. which will result in being applied and then removed causing this issue.

We should move the margin and conditions from the current place from here:
https://github.com/Expensify/App/pull/24539/files#diff-b9ff030858e3f02f7df3df9722486ca2e56c4c875b1af163819d5f980c168bf6R39
to:

return <RenderHTML html={props.source === 'email' ? `<email-comment>${htmlContent}</email-comment>` : `<comment>${htmlContent}</comment>`} />;

we also have to pass isAttachment from here:
https://github.com/Expensify/App/pull/24539/files#diff-b9ff030858e3f02f7df3df9722486ca2e56c4c875b1af163819d5f980c168bf6R37
Since the ThumbnailImage will be rendered here, it's the appropriate place to add the margin. We can wrap it with a View and apply the margin based on the conditions.

<View style={[!props.displayAsGroup && props.isAttachment ? styles.mt2 : {}]}>
     <RenderHTML ... />
</View>

What alternative solutions did you explore? (Optional)

@cubuspl42
Copy link
Contributor

@bernhardoj Damn! Indeed it looks like we missed something. We'll take the responsibility and fix this.

Would you create a PR with your suggestion? We'll move the discussion there.

@bernhardoj
Copy link
Contributor

@cubuspl42 Here is the PR #25484

@melvin-bot
Copy link

melvin-bot bot commented Aug 21, 2023

@yuwenmemon, @sophiepintoraetz Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@cubuspl42
Copy link
Contributor

cubuspl42 commented Aug 21, 2023

I created two small PRs:

After they are merged, we'll choose whether we go with a more local fix or a refactoring.

@sophiepintoraetz
Copy link
Contributor

Yup - I can reproduce - @yuwenmemon, are you comfortable assigning @cubuspl42 given their work introduced the PR?

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 2, 2023
@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Oct 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

This issue has not been updated in over 15 days. @cubuspl42, @flodnv, @sophiepintoraetz, @situchan eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@cubuspl42
Copy link
Contributor

We're working on the last fixes on the last PR

@flodnv flodnv closed this as completed in 5d914f1 Nov 15, 2023
@misgana96
Copy link

@flodnv the issue has closed without paying for reporter bonus. I think I am an eligible for the reporter bonus. Please check it again.

@flodnv flodnv reopened this Nov 15, 2023
@flodnv
Copy link
Contributor

flodnv commented Nov 15, 2023

Thanks for the call-out, we will also need to confirm it's indeed fixed.

@flodnv flodnv added Weekly KSv2 and removed Monthly KSv2 labels Nov 15, 2023
@sophiepintoraetz
Copy link
Contributor

@misgana96 - you've been paid. @cubuspl42 or @situchan, can you confirm whether this is fixed?

@situchan
Copy link
Contributor

This was accidentally closed. This should go through QA. Not hit staging yet.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 20, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Web - Chat - The display name goes down when deleting an attachment in main thread [HOLD for payment 2023-11-27] [$1000] Web - Chat - The display name goes down when deleting an attachment in main thread Nov 20, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 20, 2023
Copy link

melvin-bot bot commented Nov 20, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Nov 20, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.0-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 2023-11-27. 🎊

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:

Copy link

melvin-bot bot commented Nov 20, 2023

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:

  • [@cubuspl42 / @situchan] The PR that introduced the bug has been identified. Link to the PR:
  • [@cubuspl42 / @situchan] 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:
  • [@cubuspl42 / @situchan] 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:
  • [@cubuspl42 / @situchan] Determine if we should create a regression test for this bug.
  • [@cubuspl42 / @situchan] 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.
  • [@sophiepintoraetz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@cubuspl42
Copy link
Contributor

This doesn't formally qualify for payment, as it was a regression from a PR I was reviewing as a C+.

I would be grateful if this was treated individually, though. From my perspective, the bug had origins in the pre-existing convoluted code, which I cleaned over from unused leftovers and refactored, so a similar problem is less likely to return.

For various reasons, it took more work than I originally predicted, but I'm glad we finally merged it.

Thanks to everyone who helped review this!

@situchan
Copy link
Contributor

The bug itself is very minor and unusual case so I don't propose regression test.

@sophiepintoraetz
Copy link
Contributor

sophiepintoraetz commented Nov 28, 2023

Fair enough, @cubuspl42 - have amended the offer. @situchan - you should have an offer in your inbox for review (I'll pay it out next week as I'm actually OOO now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering Internal Requires API changes or must be handled by Expensify staff
Projects
None yet
Development

No branches or pull requests