-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Participants migration #40254
Participants migration #40254
Conversation
Found a bug in Onyx, Onyx.merge('report_123', {reportID: 123, participantAccountIDs: [10, 20]}); // have reportID and participantAccountIDs
Onyx.mergeCollection('report_', {'report_123': {participantAccountIDs: null}}) // still have reportID and participantAccountIDs <-- BUG
Onyx.merge('report_123', {participantAccountIDs: null}) // have reportID Screen.Recording.2024-04-20.at.9.46.05.PM.mov |
…, ReportScreen, ReportActionCompose
…tionsListUtilsTest, ReportUtilsTest, LHNTestUtils
…, OptionsListUtilsTest
@ikevin127 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@marcaaron There is a bug in |
This PR is held on #41056 which includes the fix for #40254 (comment). |
Code-wise this is ready for review. |
Interesting. What kind of chat was this? I have some time today to look into this. To clarify, I think it should contain your |
@marcaaron I was trying to create a 1:1 DM |
Ok, I think that everything is working correctly here? I think what you are seeing there is consistent with my expectations and not a bug. Just to be sure I understood you the first time - can you let know if you saw some other kind of bug related to this? |
I see just one problem regarding Onyx migration: |
The
That seems very wrong. I'll have a look. Let me know if you see any other inconsistencies! Thanks! |
Heads up - I'm struggling to see where in the backend we might be sending an array for the |
@ikevin127 Can you please complete the checklist |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safari *328600445-08cc485d-3970-4a2f-9c0e-af294af16b6a.movMacOS: Desktop |
This is looking great! Quick heads up that we are on a merge freeze and I likely won't get to review this until Monday, but will prioritize it as soon as possible (merge freeze should hopefully minimize the number of conflicts we get on this - but appreciate your patience on this one @s77rt 🙇). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reviewing this today! There are some small conflicts on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look very good 👍
I had a few small comments, but I think I'd prefer to merge this sooner vs. later and have them addressed in a follow up PR since this touches quite a few things and will help unblock some backend initiatives.
const participantAccountIDs = report?.participantAccountIDs ?? []; | ||
const participantAccountIDs = Object.keys(report?.participants ?? {}) | ||
.map(Number) | ||
.filter((accountID) => accountID !== session?.accountID || !isOneOnOneChat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like we should have a utility for this like ReportUtils.getAccountIDsForDisplay(report)
or something.
const visibleParticipantAccountIDs = Object.entries(report.participants ?? {}) | ||
.filter(([, participant]) => participant && !participant.hidden) | ||
.map(([accountID]) => Number(accountID)) | ||
.filter((accountID) => accountID !== currentUserAccountID || !isOneOnOneChat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAccountIDsForDisplay(report, excludeHidden)
// and add the `ownerAccountId`. Money request reports don't add `ownerAccountId` in `participantAccountIDs` array | ||
const defaultParticipantAccountIDs = finalReport?.participantAccountIDs ?? []; | ||
// For money requests i.e the IOU (1:1 person) and Expense (1:* person) reports, use the full `participants` | ||
// and add the `ownerAccountId`. Money request reports don't add `ownerAccountId` in `participants` array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment needs to be fixed. There's not participants
array anymore. Also, idk if this is true anymore. The owner needs to be added? Why? I would think they should be there already 🤔
@@ -586,12 +587,27 @@ function buildOnyxDataForMoneyRequest( | |||
}); | |||
} | |||
|
|||
const redundantParticipants: Record<number, null> = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a bit more of a comment about why we do this? It's not entirely clear. This solves the problem of potentially "optimistic" accountIDs ending up as duplicate users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@marcaaron Can you please create a new issue so I don't forget to work on the follow up |
@s77rt I've noticed that the invoice report started to show inside recents section during |
@VickyStash Thanks for reporting! Indeed this is coming from this PR due to wrong(?) optimistic participants data but I think it may have to do with the backend too. @marcaaron After sending an invoice the invoice report is as follow: You can see that it does not have any participants (and again this is somehow an array). Question: What should be the participants of the invoice report? (report.type = invoice) |
while at at, @marcaaron did you get a chance to check this bug too #40254 (comment) |
I reproduced and see the problem. I'm not sure why we use a
I will check this too. But this should be a |
Ok, I solved both of these issues, but it will take some time for the changes to go live. I don't think either are blockers for the next release. |
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.4.74-0 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.4.74-6 🚀
|
@@ -1107,7 +1107,7 @@ function isProcessingReport(report: OnyxEntry<Report> | EmptyObject): boolean { | |||
* and personal detail of participant is optimistic data | |||
*/ | |||
function shouldDisableDetailPage(report: OnyxEntry<Report>): boolean { | |||
const participantAccountIDs = report?.participantAccountIDs ?? []; | |||
const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change caused this issue
participants contains both the user and the current user, so the length is 2, as result participantAccountIDs.length === 1 condition is never satisfied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed! Thanks for fixing that
// If we have participantAccountIDs then this report is eligible for migration | ||
if (report?.participantAccountIDs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition here will be true if participantAccountIDs
is empty array []
(no need for migration in this case), and the migration in this case will remove valid accountIDs in participants in Line 65 participants[accountID] = null
, and this happened after login with new accounts, and we handled it here #45369
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is participantAccountIDs
an empty array in the first place? That was the source of truth before migrating and after migrating it should be null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is participantAccountIDs an empty array in the first place?
I think backend should not return participantAccountIDs
or return it with null
value for this case (new logged user), because the returned data is already migrated. But may be the backend doing that to prevent old version from crashes and unexpected errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
participantAccountIDs
shouldn't be returned by the backend indeed. cc @marcaaron Maybe you can double check this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this will be better if it is not affected on old versions or can cause unexpected errors, but any way we add extra check in FE for empty array here #45369
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We internally paused the project related to this so I think doing a frontend solution is fine until I am free to clean it up the whole way. Took a quick look and it's possible for this to be an empty array - but unlikely/impossible for it to have accountID values in it and we should still use the report.participants
object in all cases. Thanks!
Details
Fixed Issues
$ #34692
Tests
Test 1:
Test 2:
Test 3:
Test 4:
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov
MacOS: Desktop