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

[Awaiting C+ for payment][$500] Profile - Private notes doesn't appear on profile when navigate via Share code link #35654

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

Comments

@izarutskaya
Copy link

izarutskaya commented Feb 2, 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.35-0
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:

Precondition:
User A have a existing conversation with User B

  1. While logged out User A navigate to conversation with User B via Share code link
  2. Take a note of the Profile modal

Expected Result:

Since there is a existing conversation between users - on the Profile modal Private notes should be present

Actual Result:

Private notes does not appear on existing conversation when navigate logged out via Share code link

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

Bug6364618_1706866486295.az_recorder_20240201_222649.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0145bd5b64b244e0b6
  • Upwork Job ID: 1753374296548478976
  • Last Price Increase: 2024-02-23
  • Automatic offers:
    • shubham1206agra | Reviewer | 0
    • dukenv0307 | Contributor | 0
Issue OwnerCurrent Issue Owner: @shubham1206agra
@izarutskaya izarutskaya 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 Feb 2, 2024
Copy link

melvin-bot bot commented Feb 2, 2024

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

@melvin-bot melvin-bot bot changed the title Profile - Private notes doesn't appear on profile when navigate via Share code link [$500] Profile - Private notes doesn't appear on profile when navigate via Share code link Feb 2, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 2, 2024
Copy link

melvin-bot bot commented Feb 2, 2024

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

Copy link

melvin-bot bot commented Feb 2, 2024

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

@izarutskaya
Copy link
Author

We think that this bug might be related to #vip-vsb
CC @quinthar

@FitseTLT
Copy link
Contributor

FitseTLT commented Feb 2, 2024

Proposal

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

Private notes doesn't appear on profile when navigate via Share code link

What is the root cause of that problem?

The problem lies in how we are getting the reportID for the 1to1 chat report here as it depends on the reports list in onyx

key: ({route, session}) => {
const accountID = Number(lodashGet(route.params, 'accountID', 0));
const reportID = lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', '');
if ((session && Number(session.accountID) === accountID) || Session.isAnonymousUser() || !reportID) {
return null;
}
return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`;

As getChatByParticipants depends on the reports from onyx if it is not yet fetched from BE when the profile page is rendered it will result in null reportID and privates notes not displayed
{!_.isEmpty(props.report) && (
<MenuItem

Similarly notification preference is not shown too
const shouldShowNotificationPreference = !_.isEmpty(props.report) && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const notificationPreference = shouldShowNotificationPreference ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : '';

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

In cases where the report is empty we need to subscribe to the reports collection (onyxSubscribe) and when it is successfully populated in onyx we need to recalculate via getChatByParticipants to get report when the reports list is successfully fetched from BE in Profile Page.

What alternative solutions did you explore? (Optional)

We can also think of having the reportID data in the route in that case we don't depend on the getChatByParticipants to get the reportID

@dukenv0307
Copy link
Contributor

dukenv0307 commented Feb 5, 2024

Proposal

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

  • Profile - Private notes doesn't appear on profile when navigate via Share code link

What is the root cause of that problem?

  • In case of report data, previousKey and newKey in here are always the same, that leads to the logic here never runs. So the report data in ProfilePage is always empty. Below is detail:
  • The report key is a function, with the input is {route, session} and return the reportID. But this function also needs a reports.
  • We get the previousKey and newKey based on the prop and state of the component, but in this case, the reports does not come from prop and state, instead it is a global variable, so Str.result(mapping.key, {...prevProps, ...prevOnyxDataFromState}) and Str.result(mapping.key, {...this.props, ...onyxDataFromState}) are always the same.

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

  • Based on the above RCA, we can fix the issue by updating the report key to use the reports from component `s props and state rather than global variable.
  • For example, we can update the getChatByParticipants to:
function getChatByParticipants(newParticipantList: number[], reports = allReports): OnyxEntry<Report> {

so we can pass the reports data to it.

  • Then, update the below logic:
    export default compose(
    withLocalize,
    withOnyx({
    personalDetails: {
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    },
    session: {
    key: ONYXKEYS.SESSION,
    },
    report: {
    key: ({route, session}) => {
    const accountID = Number(lodashGet(route.params, 'accountID', 0));
    const reportID = lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', '');
    if ((session && Number(session.accountID) === accountID) || Session.isAnonymousUser() || !reportID) {
    return null;
    }
    return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`;
    },
    },
    }),
    )(ProfilePage);
    to:
export default compose(
    withLocalize,
    withOnyx(
        {
            reports: {
                key: ONYXKEYS.COLLECTION.REPORT,
            },
            personalDetails: {
                key: ONYXKEYS.PERSONAL_DETAILS_LIST,
            },
            session: {
                key: ONYXKEYS.SESSION,
            },
            report: {
+               key: ({route, session, reports}) => {
                    const accountID = Number(lodashGet(route.params, 'accountID', 0));
+                  const reportID = lodashGet(ReportUtils.getChatByParticipants([accountID], reports), 'reportID', '');
                    if ((session && Number(session.accountID) === accountID) || Session.isAnonymousUser() || !reportID) {
                        return null;
                    }
                    return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`;
                },
            },
        },
    ),
)(ProfilePage);
  • Also, we can use the selector in the above, which will just get all the properties that will be used in getChatByParticipants

What alternative solutions did you explore? (Optional)

+                  if (previousKey !== newKey || !this.activeConnectionIDs[previousKey]) {
                        Onyx_1.default.disconnect(this.activeConnectionIDs[previousKey], previousKey);
                        delete this.activeConnectionIDs[previousKey];
                        this.connectMappingToOnyx(mapping, propName, newKey);
                    }

@melvin-bot melvin-bot bot added the Overdue label Feb 5, 2024
Copy link

melvin-bot bot commented Feb 5, 2024

@miljakljajic, @shubham1206agra Whoops! This issue is 2 days overdue. Let's get this updated quick!

@miljakljajic
Copy link
Contributor

reviewing proposals still

@melvin-bot melvin-bot bot removed the Overdue label Feb 6, 2024
@shubham1206agra
Copy link
Contributor

@miljakljajic I am waiting for a better proposal. The current proposals add listeners to all reports, which I think is not a good approach.

@FitseTLT
Copy link
Contributor

FitseTLT commented Feb 6, 2024

@shubham1206agra The data the page gets from the route is accountID and it needs to get the DM report linked to that participant and if reports data is not ready we will definitely need to recalculate the getChatByParticipants when the data reports is ready. So what I am proposing is just a useEffect that will be run once on render and will only subscribe to the report collection if report is not ready at that time (what is needed in the case of this current issue) and early return for the case the report is ready and once the reports collection is ready we will populate the report and will disconnect inside the callback. I don't see an inefficiency in it.

@shubham1206agra
Copy link
Contributor

Can you give me a test branch for this?

@FitseTLT
Copy link
Contributor

FitseTLT commented Feb 6, 2024

Can you give me a test branch for this?

Will do shortly

@dukenv0307
Copy link
Contributor

@shubham1206agra Do you have any feedback about my proposal?

@shubham1206agra
Copy link
Contributor

I think I have same feedback as #35654 (comment). I just don't need to necessarily listen to all reports after initial rendering.

@FitseTLT
Copy link
Contributor

FitseTLT commented Feb 6, 2024

Here it is @shubham1206agra

@dukenv0307
Copy link
Contributor

@shubham1206agra I updated my alternative solution based on the RCA

@FitseTLT
Copy link
Contributor

FitseTLT commented Feb 6, 2024

@shubham1206agra be notified that made changes on the test branch 👍

@shubham1206agra
Copy link
Contributor

@FitseTLT I still don't like this solution.

@dukenv0307 We cannot update the Onyx logic. Maybe design a selector for all reports (Not sure if it prevents re-rendering on any change in the collection).

@dukenv0307
Copy link
Contributor

@shubham1206agra

design a selector for all reports

Can you give me more details about this one? The current behavior is that the report key here has correct key but the Onyx does not listen to that case

@shubham1206agra
Copy link
Contributor

Maybe see the SidebarLinkData component.

@dukenv0307
Copy link
Contributor

dukenv0307 commented Feb 7, 2024

@shubham1206agra yep. We just need to get all the properties that will be used in getChatByParticipants

@trjExpensify
Copy link
Contributor

Sure! Awaiting the regression period to run down melv, chill.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 4, 2024
@jasperhuangg
Copy link
Contributor

^ Same

@melvin-bot melvin-bot bot removed the Overdue label Mar 6, 2024
@jasperhuangg jasperhuangg added Weekly KSv2 and removed Daily KSv2 labels Mar 6, 2024
@trjExpensify
Copy link
Contributor

👋 Checklist time please!

@shubham1206agra
Copy link
Contributor

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:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Mar 7, 2024
@shubham1206agra
Copy link
Contributor

@trjExpensify Can you process payment here, please?

@melvin-bot melvin-bot bot added the Overdue label Mar 11, 2024
@trjExpensify
Copy link
Contributor

trjExpensify commented Mar 11, 2024

Yep! Payment summary as follows:

@dukenv0307 I've paid you. @shubham1206agra doesn't look like you've accepted the offer yet.

@melvin-bot melvin-bot bot removed the Overdue label Mar 11, 2024
@shubham1206agra
Copy link
Contributor

@trjExpensify Can you hold my payment temporarily as per https://expensify.slack.com/archives/C02NK2DQWUX/p1710150138788529?

@trjExpensify
Copy link
Contributor

Yep, please comment here when your ready. Dropping to Weekly and updating the title.

@trjExpensify trjExpensify added Weekly KSv2 and removed Daily KSv2 labels Mar 11, 2024
@trjExpensify trjExpensify changed the title [HOLD for payment 2024-03-07] [$500] Profile - Private notes doesn't appear on profile when navigate via Share code link [Awaiting C+ for payment][$500] Profile - Private notes doesn't appear on profile when navigate via Share code link Mar 11, 2024
@shubham1206agra
Copy link
Contributor

@trjExpensify I have discussed this internally. You may close this issue as I am keeping track of payment internally and will ask to pay once the issue is resolved. Just write in the payment summary that I have not been paid yet.

@trjExpensify
Copy link
Contributor

Sounds good, closing!

@shubham1206agra
Copy link
Contributor

@trjExpensify We can process payment here now.

@trjExpensify
Copy link
Contributor

Sent a new offer.

@trjExpensify trjExpensify reopened this Apr 18, 2024
@shubham1206agra
Copy link
Contributor

Accepted

@trjExpensify
Copy link
Contributor

Paid!

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. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants