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

[$250] Room - "Uh oh" error when leaving private room when parent message is highlighted #55055

Open
8 tasks done
IuliiaHerets opened this issue Jan 10, 2025 · 19 comments
Open
8 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Jan 10, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.83-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: Exp
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: Chat Report View

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to FAB > Start chat > Room.
  3. Create a private room (select Private from Visibility field).
  4. Send a message to the room.
  5. Right click on the message > Reply in thread.
  6. Click on the thread header subtitle to return to main chat.
  7. While the parent message is highlighted, click on the room header.
  8. Click Leave.

Expected Result:

App will not crash.

Actual Result:

App crashes.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6710684_1736496469088.20250110_151242.mp4

Bug6710684_1736496469086!staging.new.expensify.com-1736495466704.txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021879569257320846693
  • Upwork Job ID: 1879569257320846693
  • Last Price Increase: 2025-01-22
Issue OwnerCurrent Issue Owner: @allgandalf
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 10, 2025
Copy link

melvin-bot bot commented Jan 10, 2025

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

@nkdengineer
Copy link
Contributor

nkdengineer commented Jan 10, 2025

Edited by proposal-police: This proposal was edited at 2025-01-10 08:47:40 UTC.

Proposal

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

App crashes.

What is the root cause of that problem?

We do not pass default value to this Onyx then the app crashes when the chatReportID is changed from an empty string to an exist ID.

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

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

We should add || CONST.DEFAULT_NUMBER_ID to this

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

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

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.

@linhvovan29546
Copy link
Contributor

linhvovan29546 commented Jan 10, 2025

Edited by proposal-police: This proposal was edited at 2025-01-10 09:23:44 UTC.

Proposal

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

Room - App crashes when leaving private room when parent message is higlighted

What is the root cause of that problem?

When we leave room we set the report to null

App/src/libs/actions/Report.ts

Lines 3029 to 3030 in 219e66d

: {
reportID: null,

And We missing fallback ID here
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

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

We should add fallback report ID CONST.DEFAULT_NUMBER_ID

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

    const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID || CONST.DEFAULT_NUMBER_ID}`);

And

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

    const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID || CONST.DEFAULT_NUMBER_ID}`);

After updating the code above, the app no longer crashes. However, I noticed another issue: while the app doesn't crash, it starts spamming calls to certain functions.

Detail Screenshot 2025-01-10 at 3 54 39 PM Screenshot 2025-01-10 at 3 54 50 PM

To fix this, we need to add a fallback ID here as well:

const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportAction?.childReportID}`);

    const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportAction?.childReportID || CONST.DEFAULT_NUMBER_ID}`);

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

N/A

What alternative solutions did you explore? (Optional)

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.

@twilight2294
Copy link
Contributor

Proposal

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

App crashes when leaving private room when parent message is higlighted

What is the root cause of that problem?

When we leave a workspace in optimistic data, we set the reportID to null, this causes the useOnyx hook to read report_ which results in a crash.

App/src/libs/actions/Report.ts

Lines 3030 to 3031 in 219e66d

reportID: null,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,

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

We need FE as well as BE fix for this issue, while leaving a room, we should set the reportID to undefined this will make sure that the useOnyx hook reads the reportID correctly and the app doesn't crash.

App/src/libs/actions/Report.ts

Lines 3030 to 3031 in 219e66d

reportID: null,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,

: {
    reportID: undefined,

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

What alternative solutions did you explore? (Optional)

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Jan 10, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-10 09:26:36 UTC.

Edited by proposal-police: This proposal was edited at 2025-01-10 09:26:36 UTC.

Proposal

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

App crashes when leaving private room when parent message is higlighted

What is the root cause of that problem?

reportID is changed from report_1234 to report_ at

  1. ReportActionItemMessage
    const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
  2. BaseReportActionContextMenu

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

And that is causing the crash.

From PureReportActionItem reportID is passed to

  1. ReportActionItemMessage
    <ReportActionItemMessage
    reportID={reportID}
  2. BaseReportActionContextMenu
    <MiniReportActionContextMenu
    reportID={reportID}

And when there is no reportID, PureReportActionItem passed a default empty string id to the above two components.

const reportID = report?.reportID ?? '';

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

Following the new eslint rule, we shouldn't default to empty string or '-1' since a change from report_1234 to report_undefined doesn't cause onyx crash. Rather it won't return any report record.

const reportID = report?.reportID ?? '';

const reportID = report?.reportID

Then we should fix any type errors and lint errors that will be caused by this change according to the new
Default value for inexistent IDs guidelines. And also modify functions that use reportID in this context, and return early when reportID is undefined.

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

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Jan 13, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

@OfstadC Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@OfstadC
Copy link
Contributor

OfstadC commented Jan 13, 2025

Testing this now

@melvin-bot melvin-bot bot removed the Overdue label Jan 13, 2025
@OfstadC
Copy link
Contributor

OfstadC commented Jan 13, 2025

App doesn't crash for me 🤔

@OfstadC
Copy link
Contributor

OfstadC commented Jan 13, 2025

Tried it a few more times and I'm getting an error but no craash. Tried on iPhone & Web

Image

@OfstadC
Copy link
Contributor

OfstadC commented Jan 13, 2025

Error happens pretty consistently so I don't think this is #quality - sorting which project this should live under

@OfstadC OfstadC changed the title Room - App crashes when leaving private room when parent message is higlighted Room - "Uh oh" error when leaving private room when parent message is highlighted Jan 15, 2025
@OfstadC OfstadC added the External Added to denote the issue can be worked on by a contributor label Jan 15, 2025
@melvin-bot melvin-bot bot changed the title Room - "Uh oh" error when leaving private room when parent message is highlighted [$250] Room - "Uh oh" error when leaving private room when parent message is highlighted Jan 15, 2025
Copy link

melvin-bot bot commented Jan 15, 2025

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

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

melvin-bot bot commented Jan 15, 2025

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

@linhvovan29546
Copy link
Contributor

@allgandalf Could you please review the proposals above?

Copy link

melvin-bot bot commented Jan 21, 2025

@OfstadC, @allgandalf Eep! 4 days overdue now. Issues have feelings too...

@allgandalf
Copy link
Contributor

Reviewing today

@melvin-bot melvin-bot bot removed the Overdue label Jan 21, 2025
Copy link

melvin-bot bot commented Jan 22, 2025

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

@etCoderDysto
Copy link
Contributor

@allgandalf you might want to take a look at this dupe issue that has similar root cause to this one.

@melvin-bot melvin-bot bot added the Overdue label Jan 23, 2025
@allgandalf
Copy link
Contributor

mentioned that over here

@melvin-bot melvin-bot bot removed the Overdue label Jan 23, 2025
Copy link

melvin-bot bot commented Jan 24, 2025

@OfstadC @allgandalf 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

7 participants