Skip to content
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

[HOLD for payment 2024-02-20] [$500] Room - In offline, changing room name, in room chat changed message is not displayed #34364

Closed
3 of 6 tasks
lanitochka17 opened this issue Jan 11, 2024 · 39 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 11, 2024

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: 1.4.24
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Turn off mobile data
  3. Tap fab--- Start chat --- Room
  4. Enter all fields
  5. Tap create room
  6. Tap header
  7. Tap settings
  8. Tao room name
  9. Change room name
  10. Tap save
  11. Navite back to room chat page

Expected Result:

In offline, changing room name, in room chat changed message must be displayed

Actual Result:

In offline, changing room name, in room chat changed message is not displayed

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6338935_1704982987654.az_recorder_20240111_044733.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01cc0589030a9cc719
  • Upwork Job ID: 1745458564459560960
  • Last Price Increase: 2024-02-01
  • Automatic offers:
    • jjcoffee | Reviewer | 28142459
    • paultsimura | Contributor | 28142460
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 11, 2024
@melvin-bot melvin-bot bot changed the title Room - In offline, changing room name, in room chat changed message is not displayed [$500] Room - In offline, changing room name, in room chat changed message is not displayed Jan 11, 2024
Copy link

melvin-bot bot commented Jan 11, 2024

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

Copy link

melvin-bot bot commented Jan 11, 2024

Triggered auto assignment to @anmurali (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 11, 2024
Copy link

melvin-bot bot commented Jan 11, 2024

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

@FitseTLT
Copy link
Contributor

FitseTLT commented Jan 11, 2024

Proposal

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

In offline, changing room name, in room chat changed message is not displayed

What is the root cause of that problem?

We are only setting the updated room name in optimistic data and have not dealt with creating the renamed report action in optimisticData

App/src/libs/actions/Report.ts

Lines 1719 to 1733 in 55746c7

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
reportName: policyRoomName,
pendingFields: {
reportName: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
reportName: null,
},
},
},
];

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

We should also add the changed name message reportAction to the room in optimistic data same as what we get from the backend like

{
  "4243813452303617968": {
    "actionName": "RENAMED",
    "actorAccountID": 15732299,
    "automatic": false,
    "avatar": "https://d1wpcgnaa73g0y.cloudfront.net/509f0a093e57ea784a95033aad021fd85d1a41ce_128.jpeg",
    "created": "2024-01-11 15:03:15.316",
    "isAttachment": false,
    "lastModified": "2024-01-11 15:03:15.316",
    "message": [
      {
        "style": "strong",
        "text": "You",
        "type": "TEXT"
      },
      {
        "style": "normal",
        "text": " renamed this report. New title is '#room2' (previously '#room').",
        "type": "TEXT"
      }
    ],
    "originalMessage": {
      "html": "Room renamed to #room2",
      "lastModified": "2024-01-11 15:03:15.316",
      "newName": "#room2",
      "oldName": "#room"
    },
    "person": [
      {
        "style": "strong",
        "text": "2-Fitsum Abebe 2",
        "type": "TEXT"
      }
    ],
    "previousReportActionID": "7580374988925491109",
    "reportActionID": "4243813452303617968",
    "reportActionTimestamp": 1704985395316,
    "sequenceNumber": 1,
    "shouldShow": true,
    "timestamp": 1704985395,
    "whisperedToAccountIDs": []
  }
}
{
  "key": "report_5373863006136290",
  "onyxMethod": "merge",
  "value": {
    "lastActorAccountID": 15732299,
    "lastMentionedTime": null,
    "lastMessageText": "Room renamed to #room2",
    "lastReadTime": "2024-01-11 15:03:15.316",
    "lastVisibleActionCreated": "2024-01-11 15:03:15.316",
    "maxSequenceNumber": 1,
    "reportID": "5373863006136290"
  }
}

We should create renamed optimistic report action creator utility function in ReportUtils

function buildOptimisticRenamedReportAction(newName, oldName, created = DateUtils.getDBTime()) {
    return {
        reportActionID: NumberUtils.rand64(),
        actionName: CONST.REPORT.ACTIONS.TYPE.RENAMED,
        pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
        actorAccountID: currentUserAccountID,
        message: [
            {
                type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                style: 'strong',
                text: 'You',
            },
            {
                type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                style: 'normal',
                text: `renamed this report. New title is '${newName}' (previously '${oldName}').`,
            },
        ],
        originalMessage: {
            html: `Room renamed to ${newName}`,
            lastModified: created,
            newName,
            oldName,
        },
        person: [
            {
                type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                style: 'strong',
                text: allPersonalDetails?.[currentUserAccountID ?? '']?.displayName ?? currentUserEmail,
            },
        ],
        automatic: false,
        avatar: allPersonalDetails?.[currentUserAccountID ?? '']?.avatar ?? UserUtils.getDefaultAvatarURL(currentUserAccountID),
        created,
        shouldShow: true,
    };
}


And then add the optimisticData

const renameAction = ReportUtils.buildOptimisticRenamedReportAction(policyRoomName, previousName);

    const optimisticData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
            value: {
                [renameAction.reportActionID]: renameAction,
            },
        },

successData

const successData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
            value: {
                [renameAction.reportActionID]: {
                    pendingAction: null,
                    errors: null,
                },
            },
        },

and failureData

const failureData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
            value: {
                [renameAction.reportActionID]: {
                    errors: ErrorUtils.getMicroSecondOnyxError(null),
                },
            },
        },

Additionally, ofcourse there is a BE job to align with this change to update the api to take the reportActionID created in here as a parameter or alternatively to avoid the BE job we might delete the optimistically created report action on successData and failureData.

What alternative solutions did you explore? (Optional)

@tienifr
Copy link
Contributor

tienifr commented Jan 11, 2024

Proposal

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

In offline, changing room name, in room chat changed message is not displayed

What is the root cause of that problem?

We did not have the logic to update optimistic data for rename action in both room and workspace

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

We should create the new function named buildOptimisticRenamedReportAction to update the report action

function buildOptimisticRenamedReportAction(message, reportID){
    return {
        reportActionID: NumberUtils.rand64(),
        actionName: CONST.REPORT.ACTIONS.TYPE.RENAMED,
        pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
        actorAccountID: currentUserAccountID,
        message: [
            {
                type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                style: 'strong',
                text: 'YOU',
            },
            {
                type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                style: 'normal',
                text: ' renamed this report. New title is '#room1' (previously '#room').',
            },
        ],
        person: [
            {
                type: CONST.REPORT.MESSAGE.TYPE.TEXT,
                style: 'strong',
                text: allPersonalDetails?.[currentUserAccountID ?? '']?.displayName ?? currentUserEmail,
            },
        ],
        automatic: false,
        avatar: allPersonalDetails?.[currentUserAccountID ?? '']?.avatar ?? UserUtils.getDefaultAvatarURL(currentUserAccountID),
        created,
        shouldShow: true,

Then pass the renamed reportActionID to API's parameters, so BE can return the same report action to client (as what we already did with created action)

We need to create the translation for text and update the report respectively as well.

Improvement: Because buildOptimisticRenamedReportAction is quite same as buildOptimisticCreatedReportAction, we can consider to generic this function to support renamed action.

What alternative solutions did you explore? (Optional)

The room and WS share the same functionality so we need to update the WS as well.

@paultsimura
Copy link
Contributor

paultsimura commented Jan 11, 2024

Proposal

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

What is the root cause of that problem?

Warning

Please pay attention to the proposals' edit time. When I posted this proposal, the proposals above did not have the "send renamedActionID to BE" part, without which the solution causes duplication bugs and therefore is incomplete.

When renaming a room, we do not add an optimistic RENAME report action to the room report, only update the report name:

App/src/libs/actions/Report.ts

Lines 1706 to 1764 in c0c4d64

/**
* @param policyRoomName The updated name for the policy room
*/
function updatePolicyRoomNameAndNavigate(policyRoomReport: Report, policyRoomName: string) {
const reportID = policyRoomReport.reportID;
const previousName = policyRoomReport.reportName;
// No change needed, navigate back
if (previousName === policyRoomName) {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID));
return;
}
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
reportName: policyRoomName,
pendingFields: {
reportName: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
reportName: null,
},
},
},
];
const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
pendingFields: {
reportName: null,
},
},
},
];
const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
reportName: previousName,
},
},
];
type UpdatePolicyRoomNameParameters = {
reportID: string;
policyRoomName: string;
};
const parameters: UpdatePolicyRoomNameParameters = {reportID, policyRoomName};
API.write('UpdatePolicyRoomName', parameters, {optimisticData, successData, failureData});
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID));
}

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

First, we should build an optimistic report action with type="RENAME" and add it to the ${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID} onyx key in the optimisticData (the report action should be build to match the one we receive from BE, it's a rather trivial task):

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

Second, equally important: we should modify the UpdatePolicyRoomName API route to accept the renamedActionID parameter, so it will be used as the ID of the action received from BE.

We do similar with the task updates:

API.write(
'EditTask',
{
taskReportID: report.reportID,
title: reportName,
description: reportDescription,
editedTaskReportActionID: editTaskReportAction.reportActionID,
},
{optimisticData, successData, failureData},
);

This is needed to avoid duplicates when the BE response comes and adds another RENAMED action with a different ID.

What alternative solutions did you explore? (Optional)

To avoid BE changes, we could also remove this optimistic action on API call success or failure:

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

@FitseTLT
Copy link
Contributor

Updated to add detailed implementation

@jjcoffee
Copy link
Contributor

Sorry for the delay here, I'll review tomorrow!

@melvin-bot melvin-bot bot removed the Overdue label Jan 15, 2024
@jjcoffee
Copy link
Contributor

After an in-depth analysis of timestamps ( 😅 ), I think we can go with @tienifr's proposal. All three proposals are similar, but @tienifr got the most fully fleshed out proposal first, including an important detail of needing to translate the message text.

I do appreciate @paultsimura's proposal also included an extra detail to avoid duplicate report actions that @tienifr later included, but IMO it would've been handled in the PR anyway.

I'm not sure how long it would take to add BE support for an extra renamedActionID parameter, but if we agree to go down that route we should probably HOLD this issue until the BE changes are made.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 16, 2024

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

Copy link

melvin-bot bot commented Jan 18, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Jan 18, 2024
@flodnv
Copy link
Contributor

flodnv commented Jan 19, 2024

@neil-marcellini looks like you implemented this 5 months ago, can you check please? The proposal sounds reasonable to me, and I do think we should update the backend, as well as do this:

Because buildOptimisticRenamedReportAction is quite same as buildOptimisticCreatedReportAction, we can consider to generic this function to support renamed action.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 19, 2024
@neil-marcellini
Copy link
Contributor

@neil-marcellini looks like you implemented this 5 months ago, can you check please? The proposal sounds reasonable to me, and I do think we should update the backend, as well as do this:

Because buildOptimisticRenamedReportAction is quite same as buildOptimisticCreatedReportAction, we can consider to generic this function to support renamed action.

The proposal sounds good to me. I'm not sure what part I implemented 5 months ago. Let me know via DM if you need anything else from me.

@anmurali
Copy link

Not overdue. @flodnv and @neil-marcellini are working through what needs to change.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Overdue labels Feb 7, 2024
@paultsimura
Copy link
Contributor

Thanks. The PR is ready for review: #35826

@jjcoffee
Copy link
Contributor

jjcoffee commented Feb 8, 2024

Thanks, will review tomorrow!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Feb 13, 2024
@melvin-bot melvin-bot bot changed the title [$500] Room - In offline, changing room name, in room chat changed message is not displayed [HOLD for payment 2024-02-20] [$500] Room - In offline, changing room name, in room chat changed message is not displayed Feb 13, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Feb 13, 2024
Copy link

melvin-bot bot commented Feb 13, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Feb 13, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.40-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-02-20. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Feb 13, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@jjcoffee] The PR that introduced the bug has been identified. Link to the PR:
  • [@jjcoffee] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@jjcoffee] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@jjcoffee] Determine if we should create a regression test for this bug.
  • [@jjcoffee] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@anmurali] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@anmurali
Copy link

Due in 4 days to be paid but I am OOO so I am reassigning. @jjcoffee meanwhile, if applicable, can you add regression tests and complete the BZ checklist?

@anmurali anmurali removed their assignment Feb 16, 2024
@anmurali anmurali added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Feb 16, 2024
Copy link

melvin-bot bot commented Feb 16, 2024

Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 16, 2024
@jjcoffee
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: N/A - optimistically adding the message was never implemented
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • Determine if we should create a regression test for this bug. Yes
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression Test Proposal

  1. Open any room (or create one first)
  2. Go offline
  3. Click Header -> Settings -> Room name
  4. Change the room name
  5. Verify the "You renamed this room from $oldName to $newName" message appears
  6. Go online
  7. Verify the "You renamed this room from $oldName to $newName" persists without duplications

Do we agree 👍 or 👎

@strepanier03 strepanier03 added Weekly KSv2 and removed Daily KSv2 labels Feb 16, 2024
@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Feb 20, 2024
@strepanier03
Copy link
Contributor

Reg test created, everyone paid, closing out.

Thanks again @jjcoffee and @paultsimura for your help getting this one finished up 🙌

@melvin-bot melvin-bot bot removed the Overdue label Feb 20, 2024
@github-project-automation github-project-automation bot moved this from LOW to CRITICAL in [#whatsnext] #vip-vsb Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Status: CRITICAL
Development

No branches or pull requests

10 participants