Skip to content

[$125] Report Chat - Report change messages don't appear in un-submitted reports #67372

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.87-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #67195
Email or phone of affected tester (no customers): applausetester+uo0729@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac/Sonoma, SamsungG S22/A14, iPhone 15 Pro
App Component: Chat Report View

Action Performed:

  1. Navigate to https://staging.new.expensify.com/
  2. Log in
  3. Create workspace
  4. Create 3 expenses on the workspace (do not submit)
  5. Delete one of the expenses

Expected Result:

"Deleted an expense on this report (${merchant} - ${amount})" should be shown to user

Actual Result:

Nothing appear in report

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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021950922805670588908
  • Upwork Job ID: 1950922805670588908
  • Last Price Increase: 2025-08-07
  • Automatic offers:
    • thelullabyy | Contributor | 108379736
Issue OwnerCurrent Issue Owner: @NicMendonca

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 30, 2025
  2. melvin-bot commented on Jul 30, 2025

    @melvin-bot

    Triggered auto assignment to @NicMendonca (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. thelullabyy commented on Jul 30, 2025

    @thelullabyy
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-07-31 14:47:37 UTC.

    Proposal

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

    There are two problems:

    1. The report change message (DELETEDTRANSACTION) is not returned by the backend when deleting an expense, if the report hasn't been submitted.
    2. We do not optimistically add the report change message on the frontend when deleting an expense.

    What is the root cause of that problem?

    Problem 1: Missing DELETEDTRANSACTION from the backend

    This is a backend-side issue. The root cause should be investigated and addressed there. It’s unclear whether this is a bug or intentional behavior (i.e., only returning DELETEDTRANSACTION actions for submitted reports).

    Problem 2: Missing optimistic DELETEDTRANSACTION in the frontend

    In this section of the code, we do not currently add a DELETEDTRANSACTION report action when an expense is deleted. As a result, users don’t see the action appear in the UI immediately.

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

    Problem 1: Missing DELETEDTRANSACTION from the backend

    This should be handled by the backend. If the current behavior is intentional (i.e., only returning the DELETEDTRANSACTION action for submitted reports), that decision should be clarified and documented. If not, the backend should be updated to return the message for unsubmitted reports as well.

    Problem 2: Missing optimistic DELETEDTRANSACTION in the frontend

    We should add the following logic to optimistically create a DELETEDTRANSACTION action when an expense is deleted:

        const currentUserAccountID = getCurrentUserAccountID();
        const deletedTransactionAction: ReportAction = {
            actionName: CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION,
            actorAccountID: currentUserAccountID,
            automatic: false,
            created: DateUtils.getDBTime(),
            isAttachmentOnly: false,
            message: [
                {
                    // Currently we are composing the message from the originalMessage and message is only used in OldDot and not in the App
                    text: 'You',
                    style: 'strong',
                    type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                },
            ],
            originalMessage: {
                amount: transaction?.amount,
                currency: transaction?.currency,
                merchant: transaction?.merchant,
            },
            person: [
                {
                    style: 'strong',
                    text: currentUserPersonalDetails?.displayName ?? String(currentUserAccountID),
                    type: 'TEXT',
                },
            ],
            pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
            reportActionID: NumberUtils.rand64(),
            reportID: transactionThread?.reportID,
            shouldShow: true,
        };
        optimisticData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
            value: {[deletedTransactionAction.reportActionID]: deletedTransactionAction},
        });
    

    Then we should revert the change in failureData, clear the pending action in successData.
    Once the backend behavior for problem 1 is finalized, we can ensure the frontend conditionally applies this logic accordingly.

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

    Add test for deleteMoneyRequest to make sure the optimistic data contain the CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION action.

    What alternative solutions did you explore? (Optional)

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

    @melvin-bot
  6. changed the title [-]Report Chat - Report change messages don't appear in un-submitted reports[/-] [+][$250] Report Chat - Report change messages don't appear in un-submitted reports[/+] on Jul 31, 2025
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 31, 2025
  8. melvin-bot commented on Jul 31, 2025

    @melvin-bot

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

  9. lorretheboy commented on Jul 31, 2025

    @lorretheboy
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-07-31 14:38:48 UTC.

    Proposal

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

    Report Chat - Report change messages don't appear in un-submitted reports

    What is the root cause of that problem?

    In case report hasn't been submitted, if we delete, BE doesn't return message for that event

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

    Create optimistic deleted transaction report action in ReportUtils.ts, by using this way, the code would be more easy to maintain and increase readability. We use this approach for almost every report actions

    type OptimisticDeletedTransactionReportAction = Pick<
        ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION>,
        'actionName' | 'actorAccountID' | 'automatic' | 'avatar' | 'isAttachmentOnly' | 'originalMessage' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'created' | 'pendingAction'
    >;
    
    /**
     * Builds an optimistic DELETED_TRANSACTION report action with a randomly generated reportActionID.
     */
    function buildOptimisticDeletedTransactionReportAction(transaction: OnyxEntry<Transaction>, created = DateUtils.getDBTime()): OptimisticDeletedTransactionReportAction {
        return {
            reportActionID: rand64(),
            actionName: CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION,
            actorAccountID: currentUserAccountID,
            pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
            automatic: false,
            avatar: getCurrentUserAvatar(),
            isAttachmentOnly: false,
            message: [
                {
                    // Could add i18n here
                    text: 'You',
                    style: 'strong',
                    type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                },
            ],
            originalMessage: {
                amount: transaction?.amount,
                currency: transaction?.currency,
                merchant: transaction?.merchant,
            },
            person: [
                {
                    style: 'strong',
                    text: getCurrentUserDisplayNameOrEmail() ?? String(currentUserAccountID),
                    type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                },
            ],
            created,
            shouldShow: true,
        };
    }

    Add optimistic DELETEDTRANSACTION action to show the deletion message immediately for track expenses

        const deletedTransactionAction = buildOptimisticDeletedTransactionReportAction(transaction);
        optimisticData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
            value: {
                [deletedTransactionAction.reportActionID]: deletedTransactionAction,
            },
        });

    App/src/libs/actions/IOU.ts

    Lines 2984 to 2989 in c1edbf6

    optimisticData.push(
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
    value: updatedReportAction,
    },

    We should remove the pending action from the optimistic DELETEDTRANSACTION action

           {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
                value: {
                    [deletedTransactionAction.reportActionID]: {
                        pendingAction: null,
                    },
                },
            },

    Remove optimistic data on failure

            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
                value: {
                    [deletedTransactionAction.reportActionID]: null,
                },
            },

    failureData.push(

    const successData: OnyxUpdate[] = [

    Can reuse buildOptimisticDeletedTransactionReportAction to dd to here as well

        const deletedTransactionAction = buildOptimisticDeletedTransactionReportAction(transaction);
        optimisticData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
            value: {
                [deletedTransactionAction.reportActionID]: deletedTransactionAction,
            },
        });

    Noted: We still need BE help to update api to return correct data

    Image

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

    Add test for buildOptimisticDeletedTransactionReportAction and deleteMoneyRequest

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  10. thelullabyy commented on Jul 31, 2025

    @thelullabyy
    Contributor
  11. horodylova commented on Jul 31, 2025

    @horodylova

    Proposal

    Contributor details
    Expensify account email: hotodylova.sv@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/svitlanadev

    Problem

    When deleting an expense, no notification is shown, even though the expense is successfully removed.

    Root Cause

    The notification logic runs after the expense has already been deleted, making its data unavailable for display.

    Proposed Changes

    Trigger the notification before deleting the expense:

    1. Retrieve the expense details (merchant, amount).
    2. Display a notification: "Deleted an expense on this report (${merchant} – ${amount})".
    3. Proceed to delete the expense.

    This ensures the user sees the confirmation message while the necessary data is still available.

    Tests

    Add tests to verify that a notification is displayed for various merchant and amount values when deleting an expense.

    Alternatives

    Add a slight delay between showing the notification and performing the deletion to preserve message semantics ("Deleted" instead of "Deleting").

  12. melvin-bot commented on Jul 31, 2025

    @melvin-bot

    📣 @horodylova! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  13. 48 remaining items

  14. changed the title [-][$250] Report Chat - Report change messages don't appear in un-submitted reports[/-] [+][$125] Report Chat - Report change messages don't appear in un-submitted reports[/+] on Sep 9, 2025
  15. melvin-bot commented on Sep 9, 2025

    @melvin-bot

    ⚠️ Failed to update price automatically. The BZ team member will need to update the price manually in Upwork.

  16. NicMendonca commented on Sep 9, 2025

    @NicMendonca
    Contributor

    @thelullabyy I had to send you a new offer for the new price -- can you please accept?

  17. NicMendonca commented on Sep 9, 2025

    @NicMendonca
    Contributor

    Payment Summary

    Contributor: @thelullabyy paid $125 via Upwork
    Contributor+: @DylanDylann due $125 via NewDot

  18. NicMendonca commented on Sep 11, 2025

    @NicMendonca
    Contributor

    @thelullabyy can you please accept the Upwork offer?

  19. thelullabyy commented on Sep 12, 2025

    @thelullabyy
    Contributor

    @NicMendonca I've accepted it. Thanks!

  20. NicMendonca commented on Sep 12, 2025

    @NicMendonca
    Contributor

    Thanks! @thelullabyy done! ✅ @DylanDylann don't forget to request payment!

  21. garrettmknight commented on Oct 29, 2025

    @garrettmknight
    Contributor

    $125 approved for @DylanDylann

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