Skip to content

[Due for payment 2026-05-20] [$250] User is not redirected to the concierge chat after clearing the create chat error #83779

Closed

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.27-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @bernhardoj
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

Turn on "Simulate failing network requests"
2. Go to Inbox
3. Press the global create button > Start chat
4. Start a chat with a user you never chatted with before. The chat creation should be failed.
5. Tap the create chat error clear button

Expected Result:

User redirected to the concierge chat

Actual Result:

User stay at the error report

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

ios.mp4
ScreenRecording_02-27-2026.19-19-59_1.MP4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022027547153968189786
  • Upwork Job ID: 2027547153968189786
  • Last Price Increase: 2026-03-31

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 28, 2026
  2. melvin-bot commented on Feb 28, 2026

    @melvin-bot

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

  3. MelvinBot commented on Feb 28, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When a 1:1 chat creation fails (e.g., with "Simulate failing network requests" enabled), tapping the error clear/dismiss button does not redirect the user to the Concierge chat. The user stays on the failed report screen.

    What is the root cause of that problem?

    The openReport function's failureData for new 1:1 chat creation is missing errorFields.createChat. When the API request fails, the failure handler only sets isLoadingInitialReportActions: false on the report metadata — it does not set any error fields on the report itself.

    Specifically, at App/src/libs/actions/Report/index.ts:1660-1668, the failureData is:

    failureData = [{
        onyxMethod: Onyx.METHOD.MERGE,
        key: REPORT_METADATA,
        value: { isLoadingInitialReportActions: false },
    }];
    

    Compare this with addWorkspaceRoom at line 3593-3601, which correctly includes errorFields.addWorkspaceRoom in its failureData.

    Because errorFields.createChat is never set on failure, the OfflineWithFeedback component in ReportActionItemCreated (line 44) receives undefined for its errors prop, so no error banner is shown. And when the error IS somehow displayed and dismissed, clearCreateChatError (line 3688-3697) should call navigateToConciergeChatAndDeleteReport, but the missing error field means the flow doesn't work as intended.

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

    Add errorFields.createChat to the failureData in openReport when creating a new report (isCreatingNewReport is true and shouldAddPendingFields is true). This should be added inside the if (isCreatingNewReport) block (around line 1413) as an additional push to the failureData array:

    In App/src/libs/actions/Report/index.ts, inside the if (isCreatingNewReport) block, push to failureData:

    • Set errorFields.createChat with getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage') on the report (matching the pattern used by addWorkspaceRoom)

    This ensures:

    1. The error banner is shown via OfflineWithFeedback in ReportActionItemCreated when chat creation fails
    2. When the user taps the dismiss button, clearCreateChatError is called. Since isOptimisticReport remains true (failureData doesn't change it), the condition errorFields.createChat && !isOptimisticReport evaluates to false, correctly falling through to navigateToConciergeChatAndDeleteReport which navigates to Concierge and deletes the failed optimistic report

    What alternative solutions did you explore? (Optional)

    An alternative would be to also modify clearCreateChatError to always navigate away after clearing errors (even for non-optimistic reports). However, the current conditional logic at line 3691 is intentional — for real (non-optimistic) reports that have a createChat error from the server, clearing the error without deleting the report is correct behavior. The root cause is simply the missing error field in the failure data.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 28, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 28, 2026
  6. melvin-bot commented on Feb 28, 2026

    @melvin-bot

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

  7. melvin-bot commented on Feb 28, 2026

    @melvin-bot
  8. changed the title [-]User is not redirected to the concierge chat after clearing the create chat error[/-] [+][$250] User is not redirected to the concierge chat after clearing the create chat error[/+] on Feb 28, 2026
  9. ryntgh commented on Feb 28, 2026

    @ryntgh
    Contributor

    Proposal

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

    User is not redirected to the concierge chat after clearing the create chat error

    What is the root cause of that problem?

    clearCreateChatError uses !isOptimisticReport in its condition. On native apps, isOptimisticReport return undefined in report metadata, so !undefined is true.

    Image

    The function then clears the error and returns instead of calling navigateToConciergeChatAndDeleteReport.

    if (report?.errorFields?.createChat && !isOptimisticReport) {
    clearReportFieldKeyErrors(report.reportID, 'createChat');
    return;
    }
    navigateToConciergeChatAndDeleteReport(report?.reportID, conciergeReportID, undefined, true);

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

    We can only clear the error and return when isOptimisticReport is explicitly false. When it is true or undefined, navigate to concierge chat (and delete the report).

        if (report?.errorFields?.createChat && isOptimisticReport === false) {

    if (report?.errorFields?.createChat && !isOptimisticReport) {

    What alternative solutions did you explore? (Optional)

    N/A

  10. bernhardoj commented on Feb 28, 2026

    @bernhardoj
    Contributor

    @MelvinBot This is most likely a react-native-onyx issue.

    We add the createChat error here

    onyxData.failureData?.push(
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${chat.report?.reportID}`,
    value: {
    iouReportID: chat.report?.iouReportID,
    lastReadTime: chat.report?.lastReadTime,
    lastVisibleActionCreated: chat.report?.lastVisibleActionCreated,
    pendingFields: null,
    hasOutstandingChildRequest: chat.report?.hasOutstandingChildRequest,
    ...(isNewChatReport
    ? {
    errorFields: {
    createChat: getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage'),
    },
    }
    : {}),
    },
    },

    and when creating the chat optimistically, we already set the isOptimisticReport to true.

    if (isNewChatReport) {
    onyxData.optimisticData?.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${chat.report?.reportID}`,
    value: {
    isOptimisticReport: true,
    },
    });
    }

    But when openReport or updateLastVisitTime functions is called, it overwrites the reportMetadata that contains isOptimisticReport, even though we use MERGE operation.

    function updateLastVisitTime(reportID: string) {
    if (!isValidReportIDFromPath(reportID)) {
    return;
    }
    Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, {lastVisitTime: DateUtils.getDBTime()});
    }

    function openReport(
    reportID: string | undefined,
    introSelected: OnyxEntry<IntroSelected>,
    reportActionID?: string,
    participantLoginList: string[] = [],
    newReportObject?: OptimisticChatReport,
    parentReportActionID?: string,
    isFromDeepLink = false,
    participantAccountIDList: number[] = [],
    isNewThread = false,
    transaction?: Transaction,
    transactionViolations?: TransactionViolations,
    parentReportID?: string,
    shouldAddPendingFields = true,
    optimisticSelfDMReport?: Report,
    ) {
    if (!reportID) {
    return;
    }
    const optimisticReport = reportActionsExist(reportID)
    ? {}
    : {
    reportName: allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.reportName ?? CONST.REPORT.DEFAULT_REPORT_NAME,
    };
    const optimisticData: Array<
    OnyxUpdate<
    | typeof ONYXKEYS.COLLECTION.REPORT_METADATA
    | typeof ONYXKEYS.COLLECTION.REPORT
    | typeof ONYXKEYS.COLLECTION.TRANSACTION
    | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS
    | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS
    | typeof ONYXKEYS.NVP_INTRO_SELECTED
    | typeof ONYXKEYS.COLLECTION.POLICY
    | typeof ONYXKEYS.NVP_ONBOARDING
    | typeof ONYXKEYS.PERSONAL_DETAILS_LIST
    >
    > = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`,
    value: {
    isLoadingInitialReportActions: true,
    isLoadingOlderReportActions: false,
    hasLoadingOlderReportActionsError: false,
    isLoadingNewerReportActions: false,
    hasLoadingNewerReportActionsError: false,

  11. MelvinBot commented on Feb 28, 2026

    @MelvinBot
    Contributor

    Thanks for the feedback bernhardoj — I investigated the code references you shared and here's what I found:

    Your observation about the IOU flow is valid. In IOU/index.ts:2439-2457, errorFields.createChat IS correctly set in failureData, and isOptimisticReport: true IS correctly set in optimistic data at IOU/index.ts:2104-2112. This part of the code handles IOU-triggered chat creation properly.

    However, for the specific "Start chat" flow in this issue (Create button → Start chat → select new user), the code path is different:

    1. NewChatPage.tsx:401 → navigateToAndOpenReport → openReport with newReportObject
    2. The IOU code is not involved in this flow
    3. openReport's failureData (Report/index.ts:1660-1668) only sets {isLoadingInitialReportActions: false} — no errorFields.createChat

    Regarding the Onyx MERGE overwrite you described: I traced the Onyx internals (Onyx.js:386-402) and found that fastMerge in utils.js:9-96 does correctly preserve existing keys during a standalone MERGE. However, there IS a race condition that can cause isOptimisticReport to be lost:

    1. IOU's API.write() fires Onyx.update(optimisticData) asynchronously (fire-and-forget at API/index.ts:90)
    2. Navigation to ReportScreen happens synchronously before the Onyx cache is updated
    3. updateLastVisitTime (Report/index.ts:4934) fires from ReportScreen's useEffect — its Onyx.merge finds no value in cache yet, so the result is just {lastVisitTime: ...} without isOptimisticReport
    4. fetchReport guard at ReportScreen.tsx:535 sees isOptimisticReport as undefined → incorrectly calls openReport

    So it's not that MERGE overwrites existing keys — it's that the async Onyx operations haven't completed before the UI reads the state. This is a valid race condition that would affect the IOU-triggered chat creation flow.

    Summary — there appear to be two related bugs:

    Flow Root Cause Missing
    "Start chat" (this issue's steps) openReport failureData incomplete errorFields.createChat not set on failure
    IOU-triggered chat creation Race condition in async Onyx operations isOptimisticReport lost due to timing

    Both result in the same symptom: user stays on the error report instead of being redirected to concierge.

    If you believe the issue's reproduction steps primarily hit the IOU flow rather than the direct "Start chat" flow, I'd appreciate the clarification — that would shift the fix target toward addressing the Onyx race condition as you suggested.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  12. 128 remaining items

  13. hungvu193 commented on May 27, 2026

    @hungvu193
    Contributor

    Sounds good to me

  14. TaduJR commented on May 27, 2026

    @TaduJR
    Contributor

    Sounds good to me too.

    Thanks!

  15. mallenexpensify commented on May 27, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @TaduJR paid $500 via Upwork
    Contributor+: @hungvu193 due $500 via NewDot

    @TaduJR can you please accept the job below? Please reply here and tag me once you have.
    If you're not sent an offer in Upwork when you're assigned to an issue, and an Upwork job exists, please submit a proposal.
    https://www.upwork.com/jobs/~022059707428274199461

    ^ Test case created. Thx

  16. TaduJR commented on May 27, 2026

    @TaduJR
    Contributor

    @TaduJR in a dedicated post, can you enter your Upwork details? I'm hoping they'll be saved to send you auto-offers in the future. (please do again even if I'll already ask and you've done before) Thx

    Sure.

    If you're not sent an offer in Upwork when you're assigned to an issue, and an Upwork job exists, please submit a proposal.
    https://www.upwork.com/jobs/~022059707428274199461

    Already submitted proposal on upwork and commented before. But will do it again as you suggested.

    @mallenexpensify

    The offer says $250, Should I accept it? I think it can be edited after acceptance right?

  17. mallenexpensify commented on May 27, 2026

    @mallenexpensify
    Contributor

    Please accept @TaduJR I can always increase the price by adding a bonus

    Already submitted proposal on upwork and commented before.

    Strange, I don't see anything in Upwork. If you have a link, can you share? (Having trouble accessing Upwork right now to dive in more)

  18. JmillsExpensify commented on May 28, 2026

    @JmillsExpensify
    Contributor

    $500 approved for @hungvu193

  19. TaduJR commented on May 28, 2026

    @TaduJR
    Contributor

    Strange, I don't see anything in Upwork. If you have a link, can you share? (Having trouble accessing Upwork right now to dive in more)

    Oh I wasn't taking about the above offer. But I applied before on two proposal.

    @mallenexpensify

    When applying on upwork it says "Only invited users can find, view and apply to the job"

  20. mallenexpensify commented on May 28, 2026

    @mallenexpensify
    Contributor
  21. TaduJR commented on May 29, 2026

    @TaduJR
    Contributor

    @mallenexpensify

    Mac-Chrome.mp4

    Still the same. Am I missing something?

  22. mallenexpensify commented on May 29, 2026

    @mallenexpensify
    Contributor

    @TaduJR unsure of the bug and want to avoid a 🐰🕳 so I created another one, try this
    https://www.upwork.com/nx/wm/offer/111571398

  23. TaduJR commented on May 29, 2026

    @TaduJR
    Contributor

    Offer Accepted @mallenexpensify

    Thanks!

  24. mallenexpensify commented on May 29, 2026

    @mallenexpensify
    Contributor

    @TaduJR paid, summary updated above. Thx.
    It's $250 for the job and $250 bonus added (to get to $500 that's in the summary above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething 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