Skip to content

Next step message displayed as "... for admin" then changed to "... for you to pay #97758

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.49-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #97117
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 11 / Chrome, iPhone 13 / iOS 27 Beta, Samsung Galaxy A52 / Android 14
App Component: Chat Report View

Action Performed:

Preconditions: create a new account and create a workspace, create an expense in the workspace

Steps:

  1. Navigate to spends -> open the expense report that shows the next-step status bar in the report header.
  2. Submit then approve the expense while observing the next step in report header

Expected Result:

after approving the expense, the next-step status should displayed as "waiting for you to pay the expense" and doesn't changed to any other state because user is the admin/owner of the workspace.

Actual Result:

after approving the expense, the next-step status displayed as "waiting for an admin to pay the expense" briefly then changed to "waiting for you to pay the expense"

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7225229_1785816879321.bandicam_2026-08-04_10-20-18-571.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7225229

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @dukenv0307

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 4, 2026
  2. applause-bot commented on Aug 4, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/ad70e4a6504653910830114f5e78d7f44e1099d226859a22d5f020b9b2c9b8ab

  3. MelvinBot commented on Aug 4, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The optimistic next-step built when a report is approved uses the workspace reimburser as the payer actor, but on a brand-new workspace no reimburser/bank account is configured yet, so that ID resolves to -1. -1 renders as the generic "an admin". The message only flips to "you" once Auth responds with the real next step (which knows the actual payer).

    Chain:

    1. On approve, the optimistic APPROVED next step sets actorAccountID: reimburserAccountID — NextStepUtils.ts:275-279.
    2. getReimburserAccountID returns -1 when policy.achAccount.reimburser is empty — true for a fresh workspace with no bank account (matches the repro preconditions).
    3. buildNextStepMessage maps actorAccountID === -1 to UNSPECIFIED_ADMIN.
    4. That actor type renders "Waiting for an admin to pay expenses." instead of "Waiting for you to pay expenses.".
    5. When the server's nextStep arrives with the real payer (the owner/current user), it re-renders as "you" — producing the brief flicker.
    Why the current user is the payer here

    The APPROVED branch is only reached after the !isPayer(...) guard at NextStepUtils.ts:269, so at line 275 the current user is already known to be a payer. The optimistic code just fails to reflect that when there's no configured reimburser — it falls back to -1 ("an admin") rather than the owner/current user.

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

    In the optimistic APPROVED branch (NextStepUtils.ts:278), when reimburserAccountID is -1, fall back to the actual payer (the policy owner) instead of leaving it -1. This mirrors what the sibling nextStepFixOrPayExpense already does, where the pay actor is policy?.ownerAccountID ?? -1 (NextStepUtils.ts:120-125). With that, the optimistic message shows "you" immediately for the owner, matching what the server returns and eliminating the flicker.

    What alternative solutions did you explore? (Optional)

    Suppress rendering until the server next step arrives — rejected, as it would delay the next-step message for all approvals and hurt the offline-first experience. Fixing the optimistic actor is the smaller, more consistent change.

    Confidence: Medium-High — the code chain fully explains the exact "an admin" → "you" transition and the "new workspace / no bank account" repro preconditions. I did not runtime-verify the transient frame.

    Possibly related: #81678 (next-step pay/bank-account message) — same next-step-payer area, different symptom.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/97758) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 4, 2026
  5. melvin-bot commented on Aug 4, 2026

    @melvin-bot

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

  6. melvin-bot commented on Aug 4, 2026

    @melvin-bot
  7. j3ffffff commented on Aug 4, 2026

    @j3ffffff
  8. nkdengineer commented on Aug 5, 2026

    @nkdengineer
    Contributor

    There is inconsistent data between OpenReport and OpenPolicyWorkflowsPage.

    When we create the workspace and don't change the reimburser:

    • OpenReport returns achAccount as null.
    Image
    • OpenPolicyWorkflowsPage returns reimburser in achAccount as owner.
    Image

    So maybe we can fix this from the backend site.

    Or we need to update getReimburserAccountID to fall back to the policy's owner if payment is enabled and policy?.achAccount is undefined.

    const reimburserEmail = policy?.achAccount?.reimburser ?? '';
    
  9. melvin-bot commented on Aug 7, 2026

    @melvin-bot

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

  10. melvin-bot commented on Aug 11, 2026

    @melvin-bot

    @gijoe0295 Still overdue 6 days?! Let's take care of this!

  11. melvin-bot commented on Aug 13, 2026

    @melvin-bot

    @gijoe0295 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  12. gijoe0295 commented on Aug 17, 2026

    @gijoe0295
    Contributor

    Thank you @nkdengineer. I agree with him here that this is a backend issue due to missing policy.achAccount.reimburser in OpenReport.

    🎀 👀 🎀 C+ reviewed

  13. melvin-bot commented on Aug 17, 2026

    @melvin-bot

    Triggered auto assignment to @NicolasBonet, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  14. dukenv0307 commented on Aug 17, 2026

    @dukenv0307
    Contributor

    I'll take a look

  15. self-assigned this
    on Aug 17, 2026
  16. melvin-bot commented on Aug 18, 2026

    @melvin-bot

    @NicolasBonet @dukenv0307 @gijoe0295 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!

  17. dukenv0307 commented on Aug 19, 2026

    @dukenv0307
    Contributor

    @MelvinBot Let's create the BE issue in Expensify/Expensify then assign me

  18. MelvinBot commented on Aug 19, 2026

    @MelvinBot
    Contributor

    Created the backend issue and assigned you: Expensify/Expensify#673088

    It captures the OpenReport vs OpenPolicyWorkflowsPage achAccount inconsistency identified here and confirmed as a BE issue here, and links back to this issue for context.

  19. dukenv0307 commented on Aug 24, 2026

    @dukenv0307
    Contributor

    Fixed

    Screen.Recording.2026-08-24.at.09.18.21.mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions