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 2025-01-30] [$250] Expense - After editing expense details, page not scrolled and focused to system message #50659

Closed
3 of 6 tasks
IuliiaHerets opened this issue Oct 11, 2024 · 102 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 External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Oct 11, 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:
Reproducible in staging?: Y
Reproducible in production?: Y
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Open 1:1 chat
  3. Submit an expense
  4. Enter description and merchant

Expected Result:

After editing expense details, page must be scrolled and focused to system message.

Actual Result:

After editing expense details, page not scrolled and focused to system message.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6631952_1728660268703.screenrecorder-2024-10-11-18-34-05-385_compress_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021845669426671518848
  • Upwork Job ID: 1845669426671518848
  • Last Price Increase: 2025-01-13
Issue OwnerCurrent Issue Owner: @VictoriaExpensify
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 11, 2024
Copy link

melvin-bot bot commented Oct 11, 2024

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

@IuliiaHerets
Copy link
Author

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

@mkzie2
Copy link
Contributor

mkzie2 commented Oct 11, 2024

Proposal

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

After editing expense details, page not scrolled and focused to system message.

What is the root cause of that problem?

We don't notifyNewAction when updating all fields of money request

API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_AMOUNT_AND_CURRENCY, params, onyxData);

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

We should call notifyNewAction to scroll to the bottom after we edit the money request

Report.notifyNewAction(transactionThreadReportID, Report.getCurrentUserAccountID(), params.reportActionID);

API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_AMOUNT_AND_CURRENCY, params, onyxData);

OPTIONAL: We can check if the transaction thread report is one transaction thread we will notifyNewAction to parentReport

We should do the same for other update money request functions.

What alternative solutions did you explore? (Optional)

@VictoriaExpensify VictoriaExpensify added the External Added to denote the issue can be worked on by a contributor label Oct 14, 2024
Copy link

melvin-bot bot commented Oct 14, 2024

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

@melvin-bot melvin-bot bot changed the title Expense - After editing expense details, page not scrolled and focused to system message [$250] Expense - After editing expense details, page not scrolled and focused to system message Oct 14, 2024
@melvin-bot melvin-bot bot added Overdue Help Wanted Apply this label when an issue is open to proposals by contributors labels Oct 14, 2024
Copy link

melvin-bot bot commented Oct 14, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Oct 14, 2024
@bernhardoj
Copy link
Contributor

bernhardoj commented Oct 15, 2024

Edited by proposal-police: This proposal was edited at 2025-01-10 04:26:21 UTC.

Proposal

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

The edit system message is not shown after editing the money request.

What is the root cause of that problem?

In the video, we can see that the user is at the bottom of the chat list, but the new edit system message doesn't show. Our FlatList custom component has a config to auto-scroll to the top (or bottom because it's inverted) if the user is within the scroll threshold but only if shouldEnableAutoScrollToTopThreshold is true.

const maintainVisibleContentPosition = useMemo(() => {
const config: ScrollViewProps['maintainVisibleContentPosition'] = {
// This needs to be 1 to avoid using loading views as anchors.
minIndexForVisible: 1,
};
if (shouldEnableAutoScrollToTopThreshold) {
config.autoscrollToTopThreshold = AUTOSCROLL_TO_TOP_THRESHOLD;
}
return config;
}, [shouldEnableAutoScrollToTopThreshold]);

We only enable shouldEnableAutoScrollToTopThreshold if we have the newest report action (hasNewestReportAction)

// AutoScroll is disabled when we do linking to a specific reportAction
const shouldEnableAutoScroll = (hasNewestReportAction && (!reportActionID || !isNavigatingToLinkedMessage)) || (transactionThreadReport && !prevTransactionThreadReport);

shouldEnableAutoScrollToTopThreshold={shouldEnableAutoScroll}

hasNewestReportAction compares the last report action created with the report lastVisbileActionCreated.

const hasNewestReportAction = reportActions.at(0)?.created === report.lastVisibleActionCreated || reportActions.at(0)?.created === transactionThreadReport?.lastVisibleActionCreated;

In our case, when updating the description, for example, the new report action is added earlier before the report lastVisibleActionCreated is updated, so hasNewestReportAction is false.

Why the report lastVisibleActionCreated is late to be updated? If we see here, both report action and report are added to the optimistic data with MERGE operation.

App/src/libs/actions/IOU.ts

Lines 2560 to 2574 in 7814eed

optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThread?.reportID}`,
value: {
[updatedReportAction.reportActionID]: updatedReportAction as OnyxTypes.ReportAction,
},
});
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThread?.reportID}`,
value: {
lastVisibleActionCreated: updatedReportAction.created,
lastReadTime: updatedReportAction.created,
},
});

However, inside Onyx.update, if there are multiple collection member keys with the same collection key, they will be batched into using mergeCollection. In our case, we are updating the IOU report and transaction thread report and mergeCollection is slower than individual merge by ~150ms.

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

Update the hasNewestReportAction to return true if the lastVisibleActionCreated is bigger than the last action created time.

const hasNewestReportAction =
visibleReportActions.at(0)?.created === report.lastVisibleActionCreated || visibleReportActions.at(0)?.created === transactionThreadReport?.lastVisibleActionCreated;

const lastAction = visibleReportActions.at(0);
const hasNewestReportAction =
    lastAction?.created && ((report.lastVisibleActionCreated && lastAction.created >= report.lastVisibleActionCreated) || (transactionThreadReport?.lastVisibleActionCreated && lastAction?.created >= transactionThreadReport.lastVisibleActionCreated));

What alternative solutions did you explore? (Optional)

Alternative 1
The simplest solution is to change from MERGE to SET.

App/src/libs/actions/IOU.ts

Lines 2567 to 2574 in 7814eed

optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThread?.reportID}`,
value: {
lastVisibleActionCreated: updatedReportAction.created,
lastReadTime: updatedReportAction.created,
},
});

optimisticData.push({
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThread?.reportID}`,
    value: {
        ...transactionThread,
        lastVisibleActionCreated: updatedReportAction.created,
        lastReadTime: updatedReportAction.created,
    },
});

The batch logic will still be executed, but because we use SET, a multiSet operation will be used and it's (subs update) faster.

Alternative 2
I think I don't like the idea of automatically changing the MERGE to MERGE_COLLECTION (or multi set) when there are multiple same collection keys we are going to update because now we can't explicitly tell Onyx.update to individually update a key which we needed to solve this issue.

Before this automatic MERGE to MERGE_COLLECTION change, we used MERGE to merge individual keys and MERGE_COLLECTION to merge the collection key, which is predictable, but now, MERGE could change to MERGE_COLLECTION internally even if we want to merge it individually.

I know it would be a lot of reactors to change all action files to use MERGE_COLLECTION instead of MERGE, so, to solve that, we need to have a new attribute to each Onyx update called allowBatchedCollectionUpdate.

allowBatchedCollectionUpdate marks an update to never merge it as a collection or using multi set.

optimisticData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThread?.reportID}`,
    allowBatchedCollectionUpdate: false,
    value: {
        lastVisibleActionCreated: updatedReportAction.created,
        lastReadTime: updatedReportAction.created,
    },
});

Then,

  1. Add a new object here called nonBatchableUpdate.
  2. When iterating over the updates array, add any update that is marked with allowBatchedCollectionUpdate to the new object above.
data.forEach(({ onyxMethod, key, value, allowBatchedCollectionUpdate = true }) => {
    ...
    if (!allowBatchedCollectionUpdate) {
        nonBatchableUpdate[key] = true;
    }
})
  1. Filter out any key that shouldn't be batched update here
const collectionItemKeys = Object.keys(updateQueue).filter((key) => !nonBatchableUpdate[key] && OnyxUtils_1.default.isKeyMatch(collectionKey, key));

Copy link

melvin-bot bot commented Oct 17, 2024

@rojiphil, @VictoriaExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Oct 17, 2024
@VictoriaExpensify
Copy link
Contributor

hey @rojiphil - can you please review @bernhardoj 's proposal when you have a chance?

@melvin-bot melvin-bot bot removed the Overdue label Oct 18, 2024
Copy link

melvin-bot bot commented Oct 21, 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 Oct 21, 2024
@rojiphil
Copy link
Contributor

Sorry for the delay here. I will review this my day tomorrow and update.

@melvin-bot melvin-bot bot removed the Overdue label Oct 21, 2024
@rojiphil
Copy link
Contributor

Is anyone able to reproduce this? I am unable to reproduce as demonstrated below.

50659-nor-reproduced.mp4

@bernhardoj
Copy link
Contributor

Still reproducible

web.mp4

Copy link

melvin-bot bot commented Oct 25, 2024

@rojiphil @VictoriaExpensify this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@melvin-bot melvin-bot bot added the Overdue label Oct 25, 2024
Copy link

melvin-bot bot commented Jan 13, 2025

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

@rojiphil
Copy link
Contributor

@stitesExpensify Gentle bump for your review on comment here. Thanks

@stitesExpensify
Copy link
Contributor

Oops! Assigned!

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

PR is ready

cc: @rojiphil

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 23, 2025
@melvin-bot melvin-bot bot changed the title [$250] Expense - After editing expense details, page not scrolled and focused to system message [HOLD for payment 2025-01-30] [$250] Expense - After editing expense details, page not scrolled and focused to system message Jan 23, 2025
Copy link

melvin-bot bot commented Jan 23, 2025

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 23, 2025
Copy link

melvin-bot bot commented Jan 23, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.88-7 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 2025-01-30. 🎊

For reference, here are some details about the assignees on this issue:

  • @rojiphil requires payment through NewDot Manual Requests
  • @bernhardoj requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Jan 23, 2025

@rojiphil @VictoriaExpensify @rojiphil The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 30, 2025
Copy link

melvin-bot bot commented Jan 30, 2025

Payment Summary

Upwork Job

BugZero Checklist (@VictoriaExpensify)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1845669426671518848/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@rojiphil
Copy link
Contributor

rojiphil commented Feb 3, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production
  • 2b. Reported on staging (deploy blocker)
  • 2c. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] 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:

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: Not Required. The existing checklist is good enough to capture such issues.

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

Regression Test Proposal

Precondition:

Test:

  1. Create a money expense
  2. Open the transaction report
  3. Make sure it’s scrollable but within the scrollable threshold limit
  4. Edit the description
  5. Verify that the system message is displayed in the report.
  6. Repeat (4) and (5) until the scrollable threshold limit is reached and verify that the autoscroll stops after reaching the threshold limit

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Feb 3, 2025
@VictoriaExpensify
Copy link
Contributor

Test rail issue raised - https://github.com/Expensify/Expensify/issues/466788

@melvin-bot melvin-bot bot removed the Overdue label Feb 3, 2025
@VictoriaExpensify
Copy link
Contributor

Payment summary:
C: @bernhardoj owed $250 via NewDot
C+: @rojiphil owed $250 via NewDot

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

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 External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests

9 participants