Skip to content

fix: title image rendering in task preview and task view. #58555

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

Merged
merged 11 commits into from
Mar 26, 2025

Conversation

Krishna2323
Copy link
Contributor

@Krishna2323 Krishna2323 commented Mar 17, 2025

Explanation of Change

Fixed Issues

$ #58194
$ #58192
$ #58181
$ #58269
PROPOSAL: NA

Tests

  1. Go to chat.
  2. Click + > Assign task.
  3. Click Title.
  4. Enter the following inline image mark down:
[![300](https://picsum.photos/id/1067/200/300)](https://camo.githubusercontent.com/4848d0f965f332077b77a1a0488c3e66b4769032104f4de6890bae218b4add8d/68747470733a2f2f70696373756d2e70686f746f732f69642f313036372f3230302f333030)
  1. Save the title > verify image is not shown on the confirmation page > create the task.
  2. Verify image is not shown on the image in the task preview instead link is rendered.
  3. Open the task view > Verify link is rendered instead of the image.

Test 2

  1. Go to any chat.
  2. Create a task with multiline title.
  3. Open search router on the top right.
  4. Verify the task report is displayed with single line title

Test 3

  1. Go to staging.new.expensify.com
  2. Go to chat.
  3. Click + > Assign task.
  4. Click Title.
  5. Enter the following multiline content with markdown:
[long link name](https://github.com/Expensify/App/issues/google.com)
inline code
  1. Save the title and create the task.
  2. Click on the task preview.
  3. Verify code block does not overlap link

Test 4

  1. Select the following options during onboarding:
  2. “Manage my team’s expenses”
  3. “1-10 employees”
  4. “None”
  5. Complete the onboarding flow & validate the account (login again using magic code in mweb)
  6. Login in with same account in android app
  7. Open the Concierge chat
  8. Tap on any task in the chat
  9. Observe that the task name remains same while navigating
  • Verify that no errors appear in the JS console

Offline tests

  • Same as tests

QA Steps

  • Same as tests

  • 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 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(theme.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 the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.

Screenshots/Videos

Android: Native
android_native.mp4
Android: mWeb Chrome
android_native.mp4
iOS: Native
ios_native.mp4
iOS: mWeb Safari
ios_safari.mp4
MacOS: Chrome / Safari
web_chrome.mp4
MacOS: Desktop
desktop_app.mp4

@Krishna2323 Krishna2323 marked this pull request as ready for review March 17, 2025 13:42
@Krishna2323 Krishna2323 requested review from a team as code owners March 17, 2025 13:42
@melvin-bot melvin-bot bot requested review from mananjadhav and removed request for a team March 17, 2025 13:42
Copy link

melvin-bot bot commented Mar 17, 2025

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

@Krishna2323
Copy link
Contributor Author

@Expensify/design, please confirm if this looks fine or not, specially the image rendering and the gap between link and code block.

Monosnap.screencast.2025-03-17.20-17-44.mp4

@shawnborton
Copy link
Contributor

Hmm I feel like we don't want to support the image markdown anywhere - not in the title, not in the edit title screen, nor in the system message. It feels weird to show it in one place but not the other. Can we just remove it from all of those cases I just cited?

Unrelated, why does this report header have three lines?
CleanShot 2025-03-17 at 15 52 39@2x

@dannymcclain
Copy link
Contributor

Hmm I feel like we don't want to support the image markdown anywhere - not in the title, not in the edit title screen, nor in the system message. It feels weird to show it in one place but not the other. Can we just remove it from all of those cases I just cited?

Totally agree.

@Krishna2323
Copy link
Contributor Author

@mananjadhav, do you know how to disable image rendering in Markdown input? I'm really struggling with that. 🥴

@mananjadhav
Copy link
Collaborator

@mananjadhav, do you know how to disable image rendering in Markdown input? I'm really struggling with that. 🥴

I'll also have to check it. I think the way it'll need to be done is override the parser property. Following is an untested code:

const filterImages = (input) => {
   "worklet";
   
   const ranges = parseExpensifyMark(input);
   return ranges.filter(range => range.type !== 'inline-image');
}

Can you try this and also may be post on expensify-open-source?

Meanwhile can we skip the image part in this PR and focus on the ones we can solve?

@Krishna2323
Copy link
Contributor Author

Krishna2323 commented Mar 17, 2025

@mananjadhav thanks, I'll try that. We can leave image rendering issue on inputs. This PR covers the image rendering in task preview, task view title, task confirmation page and task title update system message.

focus on the ones we can solve?

Other linked issues in this PR are solved.

@@ -44,7 +45,8 @@ function TaskView({report}: TaskViewProps) {
useEffect(() => {
setTaskReport(report);
}, [report]);
const taskTitle = `<task-title>${convertToLTR(report?.reportName ?? '')}</task-title>`;
const htmlWithoutImage = Parser.replace(Parser.htmlToMarkdown(report?.reportName ?? ''), {disabledRules: ['image']});
Copy link
Collaborator

Choose a reason for hiding this comment

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

htmlWithoutImage is pretty generic name. Can we name it as titleWithoutImage?

@@ -145,7 +145,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret}: SearchRouterProps,
{
data: [
{
text: `${translate('search.searchIn')} ${reportForContextualSearch.text ?? reportForContextualSearch.alternateText}`,
text: StringUtils.lineBreaksToSpaces(`${translate('search.searchIn')} ${reportForContextualSearch.text ?? reportForContextualSearch.alternateText}`),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To fix this issue where search router was displaying task reports with multiline title. Task - Task with multiline title is not displayed correctly in search list #58192

@@ -4862,7 +4862,7 @@ function completeShortMention(text: string): string {
* For comments shorter than or equal to 10k chars, convert the comment from MD into HTML because that's how it is stored in the database
* For longer comments, skip parsing, but still escape the text, and display plaintext for performance reasons. It takes over 40s to parse a 100k long string!!
*/
function getParsedComment(text: string, parsingDetails?: ParsingDetails, mediaAttributes?: Record<string, string>): string {
function getParsedComment(text: string, parsingDetails?: ParsingDetails, mediaAttributes?: Record<string, string>, isTaskAction?: boolean): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about instead we pass disabledRules param?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

@@ -635,7 +635,7 @@ function getCodeFontSize(isInsideH1: boolean, isInsideTaskTitle?: boolean) {
return 15;
}
if (isInsideTaskTitle) {
return 19;
return 18;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Expensify/design can you confirm the value?

@@ -9,4 +9,8 @@ export default {
textDecorationLine: 'underline line-through',
textDecorationStyle: 'solid',
},
underlineLine: {
textDecorationLine: 'underline',
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed, this will be needed in a different PR related to regressions.

Copy link
Collaborator

@mananjadhav mananjadhav left a comment

Choose a reason for hiding this comment

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

Some clarifications and refactor comments.

@@ -64,6 +65,9 @@ function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, che
const {translate} = useLocalize();
const theme = useTheme();
const [taskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`);
const taskTitle = taskReport?.reportName ?? action?.childReportName ?? '';

const taskTitleWithoutImage = Parser.replace(Parser.htmlToMarkdown(taskTitle), {disabledRules: ['image']});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use the CONST here?

@@ -44,7 +45,8 @@ function TaskView({report}: TaskViewProps) {
useEffect(() => {
setTaskReport(report);
}, [report]);
const taskTitle = `<task-title>${convertToLTR(report?.reportName ?? '')}</task-title>`;
const titleWithoutImage = Parser.replace(Parser.htmlToMarkdown(report?.reportName ?? ''), {disabledRules: ['image']});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same use the defined CONST?

@@ -4862,7 +4862,7 @@ function completeShortMention(text: string): string {
* For comments shorter than or equal to 10k chars, convert the comment from MD into HTML because that's how it is stored in the database
* For longer comments, skip parsing, but still escape the text, and display plaintext for performance reasons. It takes over 40s to parse a 100k long string!!
*/
function getParsedComment(text: string, parsingDetails?: ParsingDetails, mediaAttributes?: Record<string, string>): string {
function getParsedComment(text: string, parsingDetails?: ParsingDetails, mediaAttributes?: Record<string, string>, disabledRules?: string[]): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can these by better typed? Say disabledRules?: MarkdownType[] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MarkdownType[] is has different properties, it does not have image.

@@ -64,6 +65,9 @@ function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, che
const {translate} = useLocalize();
const theme = useTheme();
const [taskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`);
const taskTitle = action?.childReportName ?? taskReport?.reportName ?? '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

which change is currently fixing the issue #58269 ?

@mananjadhav, I missed that initially, its now updated. We had to used action?.childReportName if it's available.

Signed-off-by: krishna2323 <[email protected]>
@Krishna2323
Copy link
Contributor Author

I removed the fix for [$50] Chat - Bold markdown is not applied for url #58349, will fix that in this PR.

@Krishna2323
Copy link
Contributor Author

@mananjadhav, could you please review this last time? I think we are almost ready to merge this one.

@mananjadhav
Copy link
Collaborator

I did the review. I need to test this. Will be doing that today.

@mananjadhav
Copy link
Collaborator

mananjadhav commented Mar 21, 2025

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 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
    • 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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.ts or at the top of the file that uses the constant) are defined as such
  • 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(theme.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 the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • 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 reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
android-task-title-fixes-1.mov
android-task-title-fallback.mov
Android: mWeb Chrome
mweb-chrome-task-title-fixes-1.mov
iOS: Native
ios-task-title-fixes-1.mov
iOS: mWeb Safari
mweb-safari-task-title-fixes-1.mov
MacOS: Chrome / Safari
web-task-title-fixes-1.mov
MacOS: Desktop
desktop-task-title-fixes-1.mov

@mananjadhav
Copy link
Collaborator

@Expensify/design Any comments on these updates

@dubielzyk-expensify
Copy link
Contributor

Hmm. I would expect us to not render the image or the markdown text. I'd expect us to only show the link and the linked text, but not the full url and markdown bit if that makes sense.

cc @Expensify/design for gut check here

@dannymcclain
Copy link
Contributor

Hmm. I would expect us to not render the image or the markdown text. I'd expect us to only show the link and the linked text, but not the full url and markdown bit if that makes sense.

Can you explain a bit more? I'm not sure I'm following.

@dubielzyk-expensify
Copy link
Contributor

dubielzyk-expensify commented Mar 24, 2025

CleanShot 2025-03-25 at 09 57 37@2x

I would expect the title of the task in the image, and everywhere, to say [Attachment] like it does in the header and only show the full markup syntax when you go in to edit the title.

@mananjadhav
Copy link
Collaborator

mananjadhav commented Mar 25, 2025

Team, while the image rendering is being discussed, I was wondering if we could merge this and images can be a follow up. I've got 2 other PRs blocked by this one that also needs to be merged. What does everyone think?

@shawnborton
Copy link
Contributor

I'm cool with that personally.

@dannymcclain
Copy link
Contributor

Same here - fine by me!

@dubielzyk-expensify
Copy link
Contributor

As long as we do a follow-up that's fine with me as well 👍

@nkuoch nkuoch merged commit 469310e into Expensify:main Mar 26, 2025
18 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.

Copy link
Contributor

🚀 Deployed to staging by https://github.com/nkuoch in version: 9.1.20-0 🚀

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

Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.1.20-2 🚀

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

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