Skip to content

[$250] Split - App crashes when tapping Copy to clipboard on code block context menu #47743

Closed

Description

@lanitochka17

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


Version Number: 9.0.22-7
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch New Expensify app
  2. Go to group chat
  3. Tap + > Spli expense > Manual
  4. Create a split manual expense with code block as the description
  5. Tap on the split preview
  6. Long press on the code block
  7. Tap Copy to clipboard

Expected Result:

App will not crash

Actual Result:

App crashes when tapping Copy to clipboard on code block context menu in split menu

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6577380_1724181250000.Screen_Recording_20240821_030954_One_UI_Home.mp4

logs (2).txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a78f1cc82b94611b
  • Upwork Job ID: 1827396760466325645
  • Last Price Increase: 2024-08-24
  • Automatic offers:
    • hoangzinh | Reviewer | 103731517
Issue OwnerCurrent Issue Owner: @hoangzinh

Activity

  1. added
    Daily
    Bug
    on Aug 20, 2024
  2. melvin-bot commented on Aug 20, 2024

    @melvin-bot

    Triggered auto assignment to @kevinksullivan (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. lanitochka17 commented on Aug 20, 2024

    @lanitochka17
    Author

    @kevinksullivan FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

  4. lanitochka17 commented on Aug 20, 2024

    @lanitochka17
    Author

    We think that this bug might be related to #vip-split

  5. Krishna2323 commented on Aug 20, 2024

    @Krishna2323
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-08-20 19:46:28 UTC.

    Proposal

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

    Split - App crashes when tapping Copy to clipboard on code block context menu

    What is the root cause of that problem?

    Context menu is not disabled when action and report are undefined.

    onLongPress={(event) =>
    showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))
    }

    What changes do you think we should make in order to solve the problem?

    • We should not call showContextMenuForReport when report or action is undefined. The check can be added before calling showContextMenuForReport or here.
    • We should also check other html renderers with same bug.

    What alternative solutions did you explore? (Optional)



    When report or action is not present, we can render TDefaultRenderer without PressableWithoutFeedback.

            <View style={isLast ? styles.mt2 : styles.mv2}>
                <ShowContextMenuContext.Consumer>
                    {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) =>
                        report && action ? (
                            <PressableWithoutFeedback
                                onPress={onPressIn ?? (() => {})}
                                onPressIn={onPressIn}
                                onPressOut={onPressOut}
                                onLongPress={(event) => {
                                    if (!report || !action) {
                                        return;
                                    }
                                    showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs));
                                }}
                                shouldUseHapticsOnLongPress
                                role={CONST.ROLE.PRESENTATION}
                                accessibilityLabel={translate('accessibilityHints.prestyledText')}
                            >
                                <View>
                                    {/* eslint-disable-next-line react/jsx-props-no-spreading */}
                                    <TDefaultRenderer {...defaultRendererProps} />
                                </View>
                            </PressableWithoutFeedback>
                        ) : (
                            <View>
                                {/* eslint-disable-next-line react/jsx-props-no-spreading */}
                                <TDefaultRenderer {...defaultRendererProps} />
                            </View>
                        )
                    }
                </ShowContextMenuContext.Consumer>
            </View>

    Result

  6. daledah commented on Aug 21, 2024

    @daledah
    Contributor

    Proposal

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

    A long press on the description field show the context menu actions.

    What is the root cause of that problem?

    • The code block is displayed as the pre tag:

      function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...defaultRendererProps}: PreRendererProps) {

    • When long pressing on it, we will call:

      showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))

    • There is the case the report or action data is undefined, because there is no ShowContextMenuContext.Provider wrapped in it, this issue for example.

    • As a result, call any context menu action, such as "Copy to clipboard" will throw the error "Cannot read properties of null (reading 'actionName')".

    What changes do you think we should make in order to solve the problem?

    • There are 4 types of context menu:
        CONTEXT_MENU_TYPES: {
            LINK: 'LINK',
            REPORT_ACTION: 'REPORT_ACTION',
            EMAIL: 'EMAIL',
            REPORT: 'REPORT',
        },
    

    we must not allow user to open context menu type REPORT_ACTION by long pressing on the description field. Because they only can open context menu type REPORT_ACTION by long pressing on the report action.

    was initially added in this PR to ensure that long-pressing on a link or email triggers context menu type LINK or EMAIL. However, this is redundant because if an email or link is wrapped in a code block like:

    abcdef@gmail.com
    

    or

    https://dev.new.expensify.com:8082/
    

    They are displayed as code, not as an active email or link. Therefore, long-pressing on them should not trigger the context menu type LINK or EMAIL.

    • So the solution is just need to remove the above onLongPress.

    What alternative solutions did you explore? (Optional)

    • In ShowContextMenuContext, we can introduce a new value in its context value, named canOpenContextMenu and its default value is false.

    • So this:

      onLongPress={(event) =>
      showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))
      }

      will be:

                            onLongPress={(event) => {
                                if (!canOpenContextMenu) {
                                    return;
                                }
                                showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs));
                            }}
    

    and just pass canOpenContextMenu: true in where in need through the ShowContextMenuContext.provider.

  7. wildan-m commented on Aug 21, 2024

    @wildan-m
    Contributor

    Proposal

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

    Context menu shown in code block in menu item

    What is the root cause of that problem?

    The context menu shouldn't be shown in codeblock in menu item

    What changes do you think we should make in order to solve the problem?

    If codeblocks are unnecessary in the menu item description, we can remove the shouldParseTitle parameter from MenuItemWithTopDescription.

    src/components/ReportActionItem/MoneyRequestView.tsx (or other similar parts)

                    <OfflineWithFeedback pendingAction={getPendingFieldAction('comment')}>
                        <MenuItemWithTopDescription
                            description={translate('common.description')}
                            shouldParseTitle
                            title={updatedTransactionDescription ?? transactionDescription}

    What alternative solutions did you explore? (Optional)

    N/A

  8. added
    External
    on Aug 24, 2024
  9. changed the title [-]Split - App crashes when tapping Copy to clipboard on code block context menu[/-] [+][$250] Split - App crashes when tapping Copy to clipboard on code block context menu[/+] on Aug 24, 2024
  10. melvin-bot commented on Aug 24, 2024

    @melvin-bot
  11. added
    Help Wanted
    on Aug 24, 2024
  12. melvin-bot commented on Aug 24, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (External)

  13. 46 remaining items

  14. melvin-bot commented on Sep 24, 2024

    @melvin-bot

    @hoangzinh, @lakchote, @kevinksullivan, @isabelastisser, @daledah 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  15. hoangzinh commented on Sep 25, 2024

    @hoangzinh
    Contributor

    PR has been deployed to staging. Awaiting for testing

  16. hoangzinh commented on Sep 25, 2024

    @hoangzinh
    Contributor

    @lakchote @isabelastisser can you help to add the "Weekly" label back for this issue? It seems to be reverted to "Daily"

  17. added
    Weekly
    and removed
    Daily
    on Sep 25, 2024
  18. lakchote commented on Sep 25, 2024

    @lakchote
    Contributor

    @lakchote @isabelastisser can you help to add the "Weekly" label back for this issue? It seems to be reverted to "Daily"

    Done.

  19. hoangzinh commented on Oct 18, 2024

    @hoangzinh
    Contributor

    BugZero Checklist:

    • The PR that introduced the bug has been identified. Link to the PR: Nope, I think it's just a new edge case that we haven't covered.
    • 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: N/A
    • 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: N/A
    • Determine if we should create a regression test for this bug: 🚫 It's just an edge case UI issue. We don't need a regression test for it.
  20. hoangzinh commented on Oct 18, 2024

    @hoangzinh
    Contributor

    cc @isabelastisser this issue is ready for payment

  21. isabelastisser commented on Oct 22, 2024

    @isabelastisser
    Contributor

    @hoangzinh, I processed your payment in Upwork.
    @daledah, please share your Upwork profile, thanks!

  22. daledah commented on Oct 29, 2024

    @daledah
    Contributor
  23. isabelastisser commented on Nov 5, 2024

    @isabelastisser
    Contributor

    @daledah, thanks! I sent you the offer in Upwork now. All set!

  24. daledah commented on Nov 6, 2024

    @daledah
    Contributor

    @isabelastisser Many thanks, offer accepted.

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

Metadata

Metadata

Labels

BugExternalReviewingWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions