Skip to content

[$250] Expense - Blank green button on expense preview & report after removing submitter offline #61639

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

Open
6 of 8 tasks
mitarachim opened this issue May 8, 2025 · 10 comments
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

@mitarachim
Copy link

mitarachim commented May 8, 2025

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.1.42-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #61098
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Log in with Expensifail accounts.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Members.
  3. Invite User B to the workspace.
  4. Disable Delay submissions and Add approvals in Workflows.
  5. As User B, go to workspace chat and submit an expense.
  6. As admin, go to workspace settings > Members.
  7. Go offline.
  8. Remove User B.
  9. Open the workspace chat with User B and the expense report (which is now archived).

Expected Result:

There will be no blank green button on the expense preview and report after removing member offline.

Actual Result:

Blank green button appears on the expense preview and report after removing member offline.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6825071_1746670150012.20250508_100416.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021922418033888325518
  • Upwork Job ID: 1922418033888325518
  • Last Price Increase: 2025-05-20
Issue OwnerCurrent Issue Owner: @ishpaul777
@mitarachim mitarachim added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 8, 2025
Copy link

melvin-bot bot commented May 8, 2025

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

@bernhardoj
Copy link
Contributor

Proposal

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

Blank green button shown after removing member from WS chat while offline.

What is the root cause of that problem?

After we remove the member from the WS, the WS chat is archived optimistically. However, reportPreviewAction still returns "PAY".

const reportPreviewAction = useMemo(() => {
// It's necessary to allow payment animation to finish before button is changed
if (isPaidAnimationRunning) {
return CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY;
}
return getReportPreviewAction(violations, iouReport, policy, transactions, isIouReportArchived, reportActions);
}, [isPaidAnimationRunning, violations, iouReport, policy, transactions, isIouReportArchived, reportActions]);

But, shouldShowPayButton is false, so the options are hidden because canIOUBePaid is false.

const shouldShowPayButton = isPaidAnimationRunning || canIOUBePaid || onlyShowPayElsewhere;

canIOUBePaid is false if the chat report is archived which is true in this case.

App/src/libs/actions/IOU.ts

Lines 8882 to 8888 in 1de2c6d

return (
isPayer &&
!isOpenExpenseReport &&
!iouSettled &&
!iouReport?.isWaitingOnBankAccount &&
reimbursableSpend > 0 &&
!isChatReportArchived &&

So, why reportPreviewAction still returns "PAY"? canPay already returns false if the report is archived.

function canPay(report: Report, violations: OnyxCollection<TransactionViolation[]>, policy?: Policy, isReportArchived = false) {
if (isReportArchived) {
return false;
}

But the report archived state we pass to the function is not the WS chat archived state, but rather, the IOU report.

return getReportPreviewAction(violations, iouReport, policy, transactions, isIouReportArchived, reportActions);

And we don't optimistically archive IOU report, so it still returns "PAY" instead of "VIEW".

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

First of all, I'm not sure why we create a new canPay when we already have canIOUBePaid, but assuming we want to use the new canPay, what we can do is either:

  1. Pass the WS chat archived state instead of the IOU report.
    return getReportPreviewAction(violations, iouReport, policy, transactions, isIouReportArchived, reportActions);

OR

  1. Optimistically archive the IOU report of a WS chat.
    workspaceChats.forEach((report) => {
    optimisticData.push(
    {
    onyxMethod: Onyx.METHOD.MERGE,
const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`] ?? {};
Object.values(reportActions).find((action) => {
    if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) {
        optimisticData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${action.childReportID}`,
            value: {
                private_isArchived: true,
            },
        });
        failureData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${action.childReportID}`,
            value: {
                private_isArchived: null,
            },
        });
    }
});

We will need to unarchive it after re-inviting the member back.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

If we go with 2, we can test remove and add member to make sure the IOU report is archived and unarchived optimistically.

@bradyrose
Copy link

bradyrose commented May 8, 2025

Withdrawing this proposal to comply with Expensify’s one-proposal-at-a-time policy.
Hope to circle back if it’s still open later. Thanks!

Copy link

melvin-bot bot commented May 13, 2025

@JmillsExpensify Eep! 4 days overdue now. Issues have feelings too...

@JmillsExpensify JmillsExpensify added the External Added to denote the issue can be worked on by a contributor label May 13, 2025
@melvin-bot melvin-bot bot changed the title Expense - Blank green button on expense preview & report after removing submitter offline [$250] Expense - Blank green button on expense preview & report after removing submitter offline May 13, 2025
Copy link

melvin-bot bot commented May 13, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 13, 2025
Copy link

melvin-bot bot commented May 13, 2025

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

@JmillsExpensify
Copy link

We have proposals so opening up to the community.

Copy link

melvin-bot bot commented May 19, 2025

@ishpaul777 Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label May 19, 2025
@ishpaul777
Copy link
Contributor

ishpaul777 commented May 19, 2025

i'll review today 🙇

@melvin-bot melvin-bot bot removed the Overdue label May 19, 2025
Copy link

melvin-bot bot commented May 20, 2025

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

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
Status: No status
Development

No branches or pull requests

5 participants