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 2024-08-22][$250] Edit Modal Not Opening by up arrow After Holding Expense and Returning to Thread #46391

Closed
1 of 6 tasks
lanitochka17 opened this issue Jul 28, 2024 · 31 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Jul 28, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.11-0
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): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to Account Settings > Workspace > Create Workspace
  2. From LHN, navigate to Workspace Chat
  3. Click the plus sign > Submit Expense > Add Amount > Add Merchant
  4. Confirm the expense, go to the thread, and go to details. Click "Hold
  5. Add a reason and hold the expense. Exit the thread
  6. Return to the thread and click the up arrow. Notice that the edit modal does not open

Expected Result:

The up arrow should always open the edit modal when the message is edited

Actual Result:

After holding the expense and exiting the thread, upon returning, the message appears in the composer, but the edit modal does not open when the up arrow is clicked

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

Bug6551098_1721779883250.Screen_Recording_2024-07-23_at_4.39.10_PM.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016ca23291c558a731
  • Upwork Job ID: 1817972655286208144
  • Last Price Increase: 2024-08-05
Issue OwnerCurrent Issue Owner: @fedirjh
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 28, 2024
Copy link

melvin-bot bot commented Jul 28, 2024

Triggered auto assignment to @puneetlath (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.

@lanitochka17
Copy link
Author

@puneetlath 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

@lanitochka17
Copy link
Author

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

@bernhardoj
Copy link
Contributor

Proposal

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

Pressing arrow up key doesn't open the edit composer in one-transaction report if the last message is the hold reason message.

What is the root cause of that problem?

The up arrow key to edit will only work if lastReportAction (editable) exists.

if (lastReportAction) {
const message = Array.isArray(lastReportAction?.message) ? lastReportAction?.message?.at(-1) ?? null : lastReportAction?.message ?? null;
Report.saveReportActionDraft(reportID, lastReportAction, Parser.htmlToMarkdown(message?.html ?? ''));
}

However, in our case, it's undefined.

lastReportAction is built from the report reportActions + parentReportAction then iterated to find the first editable message. But the hold message is the transaction thread message, so it isn't included in reportActions of the one-transaction (IOU) report.

const lastReportAction: OnyxEntry<OnyxTypes.ReportAction> = useMemo(
() =>
reportActions.length
? [...reportActions, parentReportAction].find((action) => ReportUtils.canEditReportAction(action) && !ReportActionsUtils.isMoneyRequestAction(action))
: undefined,
[reportActions, parentReportAction],
);

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

Combine the reportActions with the transaction thread report actions like we did in ReportActionsView.

const transactionThreadReportID = ...;
const [transactionThreadReportActions = []] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`, {
    canEvict: false,
    selector: (reportActions) => ReportActionsUtils.getSortedReportActionsForDisplay(reportActions, true), 
});
const lastReportAction: OnyxEntry<OnyxTypes.ReportAction> = useMemo(
    () =>
        reportActions.length
            ? [...ReportActionsUtils.getCombinedReportActions(reportActions, transactionThreadReportID ?? null, transactionThreadReportActions), parentReportAction].find((action) => ReportUtils.canEditReportAction(action) && !ReportActionsUtils.isMoneyRequestAction(action))
            : undefined,
    [reportActions, parentReportAction],
);

What alternative solutions did you explore? (Optional)

Create a new context and wrap it in ReportScreen. This context will hold a ref to the combined report actions. We will update the ref every time the combinedReportActions here is changed.

const combinedReportActions = useMemo(
() => ReportActionsUtils.getCombinedReportActions(reportActionsToDisplay, transactionThreadReportID ?? null, transactionThreadReportActions),
[reportActionsToDisplay, transactionThreadReportActions, transactionThreadReportID],
);

useEffect(() => {
    // set ref
    return () => // clears the ref
}, [combinedReportActions])

Then, when the user presses the arrow up key, we will get the report actions ref and do the filter here.

if (lastReportAction) {
const message = Array.isArray(lastReportAction?.message) ? lastReportAction?.message?.at(-1) ?? null : lastReportAction?.message ?? null;
Report.saveReportActionDraft(reportID, lastReportAction, Parser.htmlToMarkdown(message?.html ?? ''));
}

if (key === 'UP && ...) {
    const lastAction = reportActionsContext.reportActions.find((action) => ReportUtils.canEditReportAction(action) && !ReportActionsUtils.isMoneyRequestAction(action));
    ...
}

This will prevent any unnecessary and heavy re-render.

@puneetlath puneetlath added the External Added to denote the issue can be worked on by a contributor label Jul 29, 2024
@melvin-bot melvin-bot bot changed the title Edit Modal Not Opening by up arrow After Holding Expense and Returning to Thread [$250] Edit Modal Not Opening by up arrow After Holding Expense and Returning to Thread Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

Job added to Upwork: https://www.upwork.com/jobs/~016ca23291c558a731

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

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

@fedirjh
Copy link
Contributor

fedirjh commented Jul 31, 2024

I was not able to reproduce in staging v9.0.14-5

CleanShot.2024-07-31.at.18.48.47.mp4

@bernhardoj
Copy link
Contributor

bernhardoj commented Aug 1, 2024

It's still reproducible. You need to do it in a one-transaction report.

web.mp4

Copy link

melvin-bot bot commented Aug 5, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Aug 5, 2024
@puneetlath
Copy link
Contributor

@fedirjh thoughts on the proposal?

Copy link

melvin-bot bot commented Aug 5, 2024

@puneetlath, @fedirjh Huh... This is 4 days overdue. Who can take care of this?

@fedirjh
Copy link
Contributor

fedirjh commented Aug 6, 2024

I managed to reproduce the bug with a one-transaction report.

@melvin-bot melvin-bot bot removed the Overdue label Aug 6, 2024
@fedirjh
Copy link
Contributor

fedirjh commented Aug 6, 2024

@bernhardoj Why doesn't this bug appear in a multi-transaction report?

For the main solution of your proposal. Can you please clarify how you intend to get the value of transactionThreadReportID, considering that it is calculated later in the code?

@bernhardoj
Copy link
Contributor

Why doesn't this bug appear in a multi-transaction report?

It only happens in one-transaction report because the report combines report action from the expense and transaction thread. The hold reason report action message is from the transaction thread.

Can you please clarify how you intend to get the value of transactionThreadReportID, considering that it is calculated later in the code?

We can just move up the definition.

const transactionThreadReportID = useMemo(
() => ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions ?? [], isOffline),
[report.reportID, reportActions, isOffline],
);

@fedirjh
Copy link
Contributor

fedirjh commented Aug 7, 2024

@bernhardoj Perfect, I just tested the changes, and it seems to work fine.

@fedirjh
Copy link
Contributor

fedirjh commented Aug 7, 2024

Let's proceed with @bernhardoj's main solution.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Aug 7, 2024

Current assignee @puneetlath is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 8, 2024
@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Aug 9, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Aug 9, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @fedirjh

@fedirjh
Copy link
Contributor

fedirjh commented Aug 19, 2024

Note

The production deploy automation failed: This should be on [HOLD for Payment 2024-08-22] according to #47356 prod deploy checklist, confirmed in #47133 (comment).

@puneetlath puneetlath changed the title [$250] Edit Modal Not Opening by up arrow After Holding Expense and Returning to Thread [HOLD for Payment 2024-08-22][$250] Edit Modal Not Opening by up arrow After Holding Expense and Returning to Thread Aug 19, 2024
@iwiznia
Copy link
Contributor

iwiznia commented Sep 4, 2024

Just came here to say that right now I can't edit messages with up arrow at all, not sure if that means we need to hold payment of this or if something else broke it later

Copy link

melvin-bot bot commented Sep 4, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Sep 11, 2024
Copy link

melvin-bot bot commented Sep 11, 2024

This issue has not been updated in over 15 days. @puneetlath, @fedirjh, @bernhardoj 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!

@puneetlath
Copy link
Contributor

Wait, so what's the status of this? Does this need to be paid? Or is there a regression outstanding?

@bernhardoj
Copy link
Contributor

Yes, the payment is pending. No regression.

@johncschuster
Copy link
Contributor

I'd also love to get a little clarity on the status of this and how it might affect payment on the issue I was assigned.

In the issue assigned to me, @fedirjh called out a regression (comment). Is that a regression from the fix from this issue, or from something else?

@bernhardoj
Copy link
Contributor

bernhardoj commented Sep 12, 2024

It's (#48549) a regression from another issue (#48234)

@fedirjh
Copy link
Contributor

fedirjh commented Sep 12, 2024

@johncschuster The issue you have been assigned to, which is #48549, is a regression from #48052 and is not related to this one.

@puneetlath
Copy link
Contributor

Payment summary:

Thanks everyone! Please go ahead and request payment.

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

@garrettmknight
Copy link
Contributor

$250 approved for @fedirjh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

8 participants