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

[$250] After paying expense and canceling payment don't scroll down to comments #53077

Open
1 of 8 tasks
m-natarajan opened this issue Nov 25, 2024 · 9 comments
Open
1 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@m-natarajan
Copy link

m-natarajan commented Nov 25, 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.66-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
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
Expensify/Expensify Issue URL:
Issue reported by: @dukenv0307
Slack conversation (hyperlinked to channel name): ts_external_expensify_bugs

Action Performed:

  1. Submit expense > Complete the flow
  2. Pay the request
  3. Go to transaction thread > Click on header > Cancel payment

Expected Result:

After paying expense and canceling payment scroll down to the comments

Actual Result:

After paying expense and canceling payment don't scroll down to the comments

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
bug.mp4
Recording.794.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021861289275630369185
  • Upwork Job ID: 1861289275630369185
  • Last Price Increase: 2024-11-26
Issue OwnerCurrent Issue Owner: @
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 25, 2024
Copy link

melvin-bot bot commented Nov 25, 2024

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

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 25, 2024

Proposal

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

After paying expense and canceling payment don't scroll down to the comments

What is the root cause of that problem?

We do not call notifyNewAction after cancelling payment.

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

Add Report.notifyNewAction to IOU.cancelPayment

function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, chatReport: OnyxTypes.Report) {

@nkdengineer
Copy link
Contributor

Proposal

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

After paying expense and canceling payment don't scroll down

What is the root cause of that problem?

We are missing Report.notifyNewAction to scroll to the bottom when we call PayMoneyRequest API and CancelPayment API

API.write(apiCommand, params, {optimisticData, successData, failureData});

App/src/libs/actions/IOU.ts

Lines 7397 to 7406 in 51e25af

API.write(
WRITE_COMMANDS.CANCEL_PAYMENT,
{
iouReportID: expenseReport.reportID,
chatReportID: chatReport.reportID,
managerAccountID: expenseReport.managerID ?? -1,
reportActionID: optimisticReportAction.reportActionID,
},
{optimisticData, successData, failureData},
);

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

We should add notifyNewAction to scroll to the bottom here, here after calling API like we did with other actions

    Report.notifyNewAction(iouReport?.reportID ?? '', userAccountID);
    Report.notifyNewAction(expenseReport.reportID, userAccountID);

What alternative solutions did you explore? (Optional)

@dukenv0307
Copy link
Contributor

I can help take this issue as C+ since I have the context on it @kadiealexander

@kadiealexander kadiealexander added the External Added to denote the issue can be worked on by a contributor label Nov 26, 2024
Copy link

melvin-bot bot commented Nov 26, 2024

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

@melvin-bot melvin-bot bot changed the title After paying expense and canceling payment don't scroll down to comments [$250] After paying expense and canceling payment don't scroll down to comments Nov 26, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 26, 2024
Copy link

melvin-bot bot commented Nov 26, 2024

Current assignee @dukenv0307 is eligible for the External assigner, not assigning anyone new.

@FitseTLT
Copy link
Contributor

FitseTLT commented Nov 26, 2024

Proposal

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

After paying expense and canceling payment don't scroll down to comments

What is the root cause of that problem?

We already have a code that will scroll to bottom whenever the last action is changed on the report here

scrollingVerticalOffset.current < AUTOSCROLL_TO_TOP_THRESHOLD &&
previousLastIndex.current !== lastActionIndex &&
reportActionSize.current > sortedVisibleReportActions.length &&
hasNewestReportAction
) {
reportScrollManager.scrollToBottom();

but in our case hasNewesReportAction will be false
const hasNewestReportAction = lastAction?.created === lastVisibleActionCreated;

hasNewesReportAction will ensure that the last action does exist in our report action list but in our case although we added the payed and cancelled payment report actions optimistically we forgot to update lastVisibleActionCreated with the last action created timestamp

App/src/libs/actions/IOU.ts

Lines 6615 to 6625 in 084a711

[optimisticIOUReportAction.reportActionID]: {
...(optimisticIOUReportAction as OnyxTypes.ReportAction),
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID ?? ''}`,
value: {
...iouReport,

App/src/libs/actions/IOU.ts

Lines 7385 to 7395 in 084a711

...(optimisticReportAction as OnyxTypes.ReportAction),
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`,
value: {
...expenseReport,
lastMessageText: ReportActionsUtils.getReportActionText(optimisticReportAction),

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

We will need to set the lastVisibleActionCreated field correctly

...expenseReport,

               lastVisibleActionCreated: optimisticReportAction.created,

...iouReport,

                lastVisibleActionCreated: optimisticIOUReportAction.created,

and for cancel payment we need to revert previous value on failureData here

statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED,

                lastVisibleActionCreated: expenseReport.lastVisibleActionCreated,

but for pay we are already doing it here

App/src/libs/actions/IOU.ts

Lines 6673 to 6675 in 084a711

key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID ?? ''}`,
value: {
...iouReport,

POC:
2024-11-26.17-14-42.mp4

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Nov 28, 2024
@kadiealexander
Copy link
Contributor

@dukenv0307 bump!

@melvin-bot melvin-bot bot removed the Overdue label Nov 28, 2024
@dukenv0307
Copy link
Contributor

I'm reviewing.

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

6 participants