Skip to content

[$125] LHN - "Unheld this expense" disappears from report preview on LHN after opening it. #65226

Closed

Description

@jponikarchuk

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.1.73-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: https://expensify.testrail.io/index.php?/tests/view/6408538&group_by=cases:section_id&group_order=asc&group_id=309128
Email or phone of affected tester (no customers): ibellicotest+1199@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 - Android 12 - Chrome (mWeb - Hybrid App) / Windows 10 - Chrome
App Component: Left Hand Navigation (LHN)

Action Performed:

Prerequisite: Account has at least one workspace created.

  1. Open the Expensify app.
  2. Open any workspace chat.
  3. Submit two manual expenses to it.
  4. Open the report of the just created expenses.
  5. Long tap on any of the expenses and select it.
  6. Hold the selected expense.
  7. Add any reason to hold it.
  8. Select the same expense and remove hold.
  9. Navigate to "Inbox"
  10. Note that the preview of the report, shows a "Unheld this expense" message.
  11. Open report and return to inbox.
  12. Note that now, report preview shows the last message sent before the expense was unheld.

Expected Result:

System message shown on LHN after unholding an expense, shouldn´t disappear from preview after opening report.

Actual Result:

System message generated after unholding an expense, disappears from report preview on LHN, after opening the report. After report is opened, preview shows the last message sent before unholding the expense.

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

bandicam.2025-07-01.07-47-50-616.1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021940426879587963556
  • Upwork Job ID: 1940426879587963556
  • Last Price Increase: 2025-08-20

Activity

  1. added
    Daily
    Bug
    on Jul 1, 2025
  2. melvin-bot commented on Jul 1, 2025

    @melvin-bot

    Triggered auto assignment to @joekaufmanexpensify (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. nyomanjyotisa commented on Jul 1, 2025

    @nyomanjyotisa
    Member

    Proposal

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

    LHN - "Unheld this expense" disappears from report preview on LHN after opening it

    What is the root cause of that problem?

    Currently we don't have check for HOLD and UNHOLD actions in getLastMessageTextForReport

    function getLastMessageTextForReport(

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

    Add handling for HOLD/UNHOLD actions in getLastMessageTextForReport here

        } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.HOLD)) {
            lastMessageTextFromReport = translateLocal('iou.heldExpense');
        } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.UNHOLD)) {
            lastMessageTextFromReport = translateLocal('iou.unheldExpense');
        }
    

    We should fix the actor determination here as well to address the issue based on this comment

    const lastActorAccountID = report.lastActorAccountID || lastAction?.actorAccountID;

        const lastActorAccountID = lastAction?.actorAccountID || report.lastActorAccountID;
    

    We should prioritize getting the actor ID from the action itself rather than the report last actor, which can be incorrect for system messages

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

    None

    What alternative solutions did you explore? (Optional)

    Or just add handling for UNHOLD only

        } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.HOLD)) {
            lastMessageTextFromReport = translateLocal('iou.heldExpense');
        }
    

    Image

    Image

  4. nabi-ebrahimi commented on Jul 1, 2025

    @nabi-ebrahimi
    Contributor

    Proposal

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

    LHN - "Unheld this expense" disappears from report preview on LHN after opening it.

    What is the root cause of that problem?

    In the OpenReport API call result, the lastMessageText is the last message. In the chat.

    Image

    We never check the hold and unhold actions to show the last action message in getLastMessageTextForReport function

    function getLastMessageTextForReport(
    report: OnyxEntry<Report>,
    lastActorDetails: Partial<PersonalDetails> | null,
    policy?: OnyxEntry<Policy>,
    reportNameValuePairs?: OnyxInputOrEntry<ReportNameValuePairs>,
    ): string {
    const reportID = report?.reportID;
    const lastReportAction = reportID ? lastVisibleReportActions[reportID] : undefined;
    // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
    const lastOriginalReportAction = reportID ? lastReportActions[reportID] : undefined;
    let lastMessageTextFromReport = '';
    if (isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived)) {
    const archiveReason =
    // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
    (isClosedAction(lastOriginalReportAction) && getOriginalMessage(lastOriginalReportAction)?.reason) || CONST.REPORT.ARCHIVE_REASON.DEFAULT;
    switch (archiveReason) {
    case CONST.REPORT.ARCHIVE_REASON.ACCOUNT_CLOSED:
    case CONST.REPORT.ARCHIVE_REASON.REMOVED_FROM_POLICY:
    case CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED: {
    lastMessageTextFromReport = translateLocal(`reportArchiveReasons.${archiveReason}`, {
    displayName: formatPhoneNumber(getDisplayNameOrDefault(lastActorDetails)),
    policyName: getPolicyName({report, policy}),
    });
    break;
    }
    case CONST.REPORT.ARCHIVE_REASON.BOOKING_END_DATE_HAS_PASSED: {
    lastMessageTextFromReport = translateLocal(`reportArchiveReasons.${archiveReason}`);
    break;
    }
    default: {
    lastMessageTextFromReport = translateLocal(`reportArchiveReasons.default`);
    }
    }
    } else if (isMoneyRequestAction(lastReportAction)) {
    const properSchemaForMoneyRequestMessage = getReportPreviewMessage(report, lastReportAction, true, false, null, true);
    lastMessageTextFromReport = formatReportLastMessageText(properSchemaForMoneyRequestMessage);
    } else if (isReportPreviewAction(lastReportAction)) {
    const iouReport = getReportOrDraftReport(getIOUReportIDFromReportActionPreview(lastReportAction));
    const lastIOUMoneyReportAction = iouReport?.reportID
    ? allSortedReportActions[iouReport.reportID]?.find(
    (reportAction, key): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
    shouldReportActionBeVisible(reportAction, key, canUserPerformWriteAction(report)) &&
    reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
    isMoneyRequestAction(reportAction),
    )
    : undefined;
    const reportPreviewMessage = getReportPreviewMessage(
    !isEmptyObject(iouReport) ? iouReport : null,
    lastIOUMoneyReportAction ?? lastReportAction,
    true,
    reportUtilsIsChatReport(report),
    null,
    true,
    lastReportAction,
    );
    lastMessageTextFromReport = formatReportLastMessageText(reportPreviewMessage);
    } else if (isReimbursementQueuedAction(lastReportAction)) {
    lastMessageTextFromReport = getReimbursementQueuedActionMessage({reportAction: lastReportAction, reportOrID: report});
    } else if (isReimbursementDeQueuedOrCanceledAction(lastReportAction)) {
    lastMessageTextFromReport = getReimbursementDeQueuedOrCanceledActionMessage(lastReportAction, report, true);
    } else if (isDeletedParentAction(lastReportAction) && reportUtilsIsChatReport(report)) {
    lastMessageTextFromReport = getDeletedParentActionMessageForChatReport(lastReportAction);
    } else if (isPendingRemove(lastReportAction) && report?.reportID && isThreadParentMessage(lastReportAction, report.reportID)) {
    lastMessageTextFromReport = translateLocal('parentReportAction.hiddenMessage');
    } else if (isReportMessageAttachment({text: report?.lastMessageText ?? '', html: report?.lastMessageHtml, type: ''})) {
    lastMessageTextFromReport = `[${translateLocal('common.attachment')}]`;
    } else if (isModifiedExpenseAction(lastReportAction)) {
    const properSchemaForModifiedExpenseMessage = ModifiedExpenseMessage.getForReportAction({reportOrID: report?.reportID, reportAction: lastReportAction});
    lastMessageTextFromReport = formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true);
    } else if (isMovedTransactionAction(lastReportAction)) {
    const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
    const movedIOUReport = isExpenseReport(parentReport) ? parentReport : report;
    lastMessageTextFromReport = getMovedTransactionMessage(lastReportAction, movedIOUReport);
    } else if (isTaskAction(lastReportAction)) {
    lastMessageTextFromReport = formatReportLastMessageText(getTaskReportActionMessage(lastReportAction).text);
    } else if (isCreatedTaskReportAction(lastReportAction)) {
    lastMessageTextFromReport = getTaskCreatedMessage(lastReportAction);
    } else if (
    isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) ||
    isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) ||
    isMarkAsClosedAction(lastReportAction)
    ) {
    const wasSubmittedViaHarvesting = !isMarkAsClosedAction(lastReportAction) ? (getOriginalMessage(lastReportAction)?.harvesting ?? false) : false;
    if (wasSubmittedViaHarvesting) {
    lastMessageTextFromReport = translateLocal('iou.automaticallySubmitted');
    } else {
    lastMessageTextFromReport = translateLocal('iou.submitted');
    }
    } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.APPROVED)) {
    const {automaticAction} = getOriginalMessage(lastReportAction) ?? {};
    if (automaticAction) {
    lastMessageTextFromReport = translateLocal('iou.automaticallyApproved');
    } else {
    lastMessageTextFromReport = translateLocal('iou.approvedMessage');
    }
    } else if (isUnapprovedAction(lastReportAction)) {
    lastMessageTextFromReport = translateLocal('iou.unapproved');
    } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) {
    const {automaticAction} = getOriginalMessage(lastReportAction) ?? {};
    if (automaticAction) {
    lastMessageTextFromReport = translateLocal('iou.automaticallyForwarded');
    } else {
    lastMessageTextFromReport = translateLocal('iou.forwarded');
    }
    } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) {
    lastMessageTextFromReport = getRejectedReportMessage();
    } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) {
    lastMessageTextFromReport = getUpgradeWorkspaceMessage();
    } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) {
    lastMessageTextFromReport = getDowngradeWorkspaceMessage();
    } else if (isActionableAddPaymentCard(lastReportAction) || isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.MOVED)) {
    lastMessageTextFromReport = getReportActionMessageText(lastReportAction);
    } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) {
    lastMessageTextFromReport = getExportIntegrationLastMessageText(lastReportAction);
    } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED) {
    lastMessageTextFromReport = getReceiptScanFailedMessage();
    } else if (lastReportAction?.actionName && isOldDotReportAction(lastReportAction)) {
    lastMessageTextFromReport = getMessageOfOldDotReportAction(lastReportAction, false);
    } else if (isActionableJoinRequest(lastReportAction)) {
    lastMessageTextFromReport = getJoinRequestMessage(lastReportAction);
    } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.LEAVE_ROOM) {
    lastMessageTextFromReport = getLeaveRoomMessage();
    } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES) {
    lastMessageTextFromReport = translateLocal('violations.resolvedDuplicates');
    } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) {
    lastMessageTextFromReport = getUpdateRoomDescriptionMessage(lastReportAction);
    } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.RETRACTED)) {
    lastMessageTextFromReport = getRetractedMessage();
    } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.REOPENED)) {
    lastMessageTextFromReport = getReopenedMessage();
    } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY)) {
    lastMessageTextFromReport = getPolicyChangeMessage(lastReportAction);
    } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) {
    lastMessageTextFromReport = getTravelUpdateMessage(lastReportAction);
    }
    // we do not want to show report closed in LHN for non archived report so use getReportLastMessage as fallback instead of lastMessageText from report
    if (
    reportID &&
    !isArchivedReport(reportNameValuePairs) &&
    (report.lastActionType === CONST.REPORT.ACTIONS.TYPE.CLOSED || (lastOriginalReportAction?.reportActionID && isDeletedAction(lastOriginalReportAction)))
    ) {
    return lastMessageTextFromReport || (getReportLastMessage(reportID).lastMessageText ?? '');
    }
    // When the last report action has unknown mentions (@Hidden), we want to consistently show @Hidden in LHN and report screen
    // so we reconstruct the last message text of the report from the last report action.
    if (!lastMessageTextFromReport && lastReportAction && hasHiddenDisplayNames(getMentionedAccountIDsFromAction(lastReportAction))) {
    lastMessageTextFromReport = Parser.htmlToText(getReportActionHtml(lastReportAction));
    }
    // If the last report action is a pending moderation action, get the last message text from the last visible report action
    if (reportID && !lastMessageTextFromReport && isPendingRemove(lastOriginalReportAction)) {
    lastMessageTextFromReport = getReportActionMessageText(lastReportAction);
    }
    return lastMessageTextFromReport || (report?.lastMessageText ?? '');
    }

    and return the report.lastMessageText

    if (reportID && !lastMessageTextFromReport && isPendingRemove(lastOriginalReportAction)) {
    lastMessageTextFromReport = getReportActionMessageText(lastReportAction);
    }
    return lastMessageTextFromReport || (report?.lastMessageText ?? '');
    }

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

    We should consider Hold and unHold actions When get last message text for sidebar. we need to add this code snippet in getLastMessageTextForReport function

       if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.HOLD)) {
            lastMessageTextFromReport = translateLocal('iou.heldExpense');
        } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.UNHOLD)) {
            lastMessageTextFromReport = translateLocal('iou.unheldExpense');
        }

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

    None

    What alternative solutions did you explore? (Optional)

    We can only add Unhold in getLastMessageTextForReport function

    if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.UNHOLD)) {
            lastMessageTextFromReport = translateLocal('iou.unheldExpense');
        }
  5. joekaufmanexpensify commented on Jul 1, 2025

    @joekaufmanexpensify
    Contributor

    @jponikarchuk I'm having trouble following what the bug is here. I don't think the video above is correct. Could you add the correct video for this bug to the issue?

  6. joekaufmanexpensify commented on Jul 2, 2025

    @joekaufmanexpensify
    Contributor

    I was able to figure it out and can reproduce 👍

    2025-07-02_11-04-42.mp4
  7. joekaufmanexpensify commented on Jul 2, 2025

    @joekaufmanexpensify
    Contributor

    I replaced the video in OP so it is more clear.

  8. joekaufmanexpensify commented on Jul 2, 2025

    @joekaufmanexpensify
    Contributor

    This is a pretty minor bug, but it is incorrect, so we can fix it.

  9. added
    External
    on Jul 2, 2025
  10. changed the title [-]LHN - "Unheld this expense" disappears from report preview on LHN after opening it.[/-] [+][$250] LHN - "Unheld this expense" disappears from report preview on LHN after opening it.[/+] on Jul 2, 2025
  11. melvin-bot commented on Jul 2, 2025

    @melvin-bot
  12. added
    Help Wanted
    on Jul 2, 2025
  13. 60 remaining items

  14. joekaufmanexpensify commented on Aug 18, 2025

    @joekaufmanexpensify
    Contributor

    Sounds good!

  15. joekaufmanexpensify commented on Aug 18, 2025

    @joekaufmanexpensify
    Contributor

    @nabi-ebrahimi have you had a chance to look into this?

  16. nabi-ebrahimi commented on Aug 18, 2025

    @nabi-ebrahimi
    Contributor

    @joekaufmanexpensify Yes, but I can not hold expenses on step 6.

  17. joekaufmanexpensify commented on Aug 19, 2025

    @joekaufmanexpensify
    Contributor

    @nabi-ebrahimi Could you share more about what you mean? The hold button is not working for you?

  18. nabi-ebrahimi commented on Aug 19, 2025

    @nabi-ebrahimi
    Contributor
  19. nabi-ebrahimi commented on Aug 19, 2025

    @nabi-ebrahimi
    Contributor

    @joekaufmanexpensify I provided a video record which shows what I mean.

  20. joekaufmanexpensify commented on Aug 19, 2025

    @joekaufmanexpensify
    Contributor

    Responded there 👍

  21. nabi-ebrahimi commented on Aug 20, 2025

    @nabi-ebrahimi
    Contributor

    @joekaufmanexpensify thanks, I did further investigation, the original issue is not reproducible in the latest main.

    Screen.Recording.1404-05-29.at.10.25.38.AM.mp4

    Although I think there is another issue that shows unheld this money request instead of unheld this expense. This issue can be fixed by considering the hold and unhold actions in getLastMessageTextForReport.

    @sobitneupane, I am available to do further investigation if needed.

  22. melvin-bot commented on Aug 20, 2025

    @melvin-bot

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

  23. joekaufmanexpensify commented on Aug 21, 2025

    @joekaufmanexpensify
    Contributor

    Although I think there is another issue that shows unheld this money request instead of unheld this expense. This issue can be fixed by considering the hold and unhold actions in getLastMessageTextForReport.

    I am only seeing unheld this expense this expense personally. Regardless, that feels like a different issue.

  24. joekaufmanexpensify commented on Aug 21, 2025

    @joekaufmanexpensify
    Contributor

    Yeah, I also can't reproduce anymore, so going to close this out. Thanks everyone!

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

Metadata

Metadata

Labels

BugDailyExternalHelp Wanted

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions