-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Merged
Merged
Participants migration #40254
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
92a6265
Participants onyx migration
s77rt 57c8c70
Merge branch 'Expensify:main' into participants-migration
s77rt 07356fb
Participants migration: ReportUtils, OptionsListUtils, ReportWelcomeText
s77rt bc24bfa
remove diff.tmp
s77rt 54745c9
Merge branch 'Expensify:main' into participants-migration
s77rt ea56625
Participants migration: SidebarUtils, IOU, Task
s77rt f2ba3a3
Merge branch 'main' into participants-migration
s77rt bfba18d
Participants migration: Task, Report, Policy, HeaderView, ProfilePage…
s77rt 716c944
Participants migration: IOUTest, PolicyTest, UnreadIndicatorsTest, Op…
s77rt 4ec3fb5
Participants migration: useReportIDs, RoomInvitePage, RoomMembersPage…
s77rt a3dcdda
Participants migration: lint
s77rt a85a08b
Merge branch 'main' into participants-migration
s77rt ccb420b
Fix isMultipleParticipant condition
s77rt 9f6afd8
fix participants length
s77rt 5338841
Fix getChatByParticipants
s77rt 35ed090
fix more tests
s77rt a4853b6
Fix IOUTest and lint
s77rt e56163f
Onyx migration: add current user as a participant
s77rt c0d0f7c
Merge branch 'Expensify:main' into participants-migration
s77rt 2733e47
Clear optimistic participants on OpenReport
s77rt 4231757
Clear optimistic participants on IOU
s77rt a91f310
Clear optimistic participants on Task
s77rt e247a3b
Fix IOUTest
s77rt 540e535
Merge branch 'main' into participants-migration
s77rt 8d43462
Onyx migration: correct reports by removing invalid participants
s77rt 30e119e
Add assigneeAccountID to participants only if it's set
s77rt 2d7587a
Merge branch 'Expensify:main' into participants-migration
s77rt 1d27719
Make filter condition more readable
s77rt 7234ceb
Merge branch 'main' into participants-migration
s77rt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -709,11 +709,20 @@ function createOption( | |
result.isPinned = report.isPinned; | ||
result.iouReportID = report.iouReportID; | ||
result.keyForList = String(report.reportID); | ||
result.tooltipText = ReportUtils.getReportParticipantsTitle(report.visibleChatMemberAccountIDs ?? []); | ||
result.isWaitingOnBankAccount = report.isWaitingOnBankAccount; | ||
result.policyID = report.policyID; | ||
result.isSelfDM = ReportUtils.isSelfDM(report); | ||
|
||
// For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants | ||
const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
result.tooltipText = ReportUtils.getReportParticipantsTitle(visibleParticipantAccountIDs); | ||
result.isOneOnOneChat = isOneOnOneChat; | ||
|
||
hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat; | ||
subtitle = ReportUtils.getChatRoomSubtitle(report); | ||
|
||
|
@@ -776,8 +785,15 @@ function createOption( | |
function getReportOption(participant: Participant): ReportUtils.OptionData { | ||
const report = ReportUtils.getReport(participant.reportID); | ||
|
||
// For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants | ||
const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); | ||
const visibleParticipantAccountIDs = Object.entries(report?.participants ?? {}) | ||
.filter(([, reportParticipant]) => reportParticipant && !reportParticipant.hidden) | ||
.map(([accountID]) => Number(accountID)) | ||
.filter((accountID) => accountID !== currentUserAccountID || !isOneOnOneChat); | ||
|
||
const option = createOption( | ||
report?.visibleChatMemberAccountIDs ?? [], | ||
visibleParticipantAccountIDs, | ||
allPersonalDetails ?? {}, | ||
!isEmptyObject(report) ? report : null, | ||
{}, | ||
|
@@ -806,8 +822,12 @@ function getReportOption(participant: Participant): ReportUtils.OptionData { | |
function getPolicyExpenseReportOption(participant: Participant | ReportUtils.OptionData): ReportUtils.OptionData { | ||
const expenseReport = ReportUtils.isPolicyExpenseChat(participant) ? ReportUtils.getReport(participant.reportID) : null; | ||
|
||
const visibleParticipantAccountIDs = Object.entries(expenseReport?.participants ?? {}) | ||
.filter(([, reportParticipant]) => reportParticipant && !reportParticipant.hidden) | ||
.map(([accountID]) => Number(accountID)); | ||
|
||
const option = createOption( | ||
expenseReport?.visibleChatMemberAccountIDs ?? [], | ||
visibleParticipantAccountIDs, | ||
allPersonalDetails ?? {}, | ||
!isEmptyObject(expenseReport) ? expenseReport : null, | ||
{}, | ||
|
@@ -1467,19 +1487,11 @@ function createOptionList(personalDetails: OnyxEntry<PersonalDetailsList>, repor | |
return; | ||
} | ||
|
||
const isSelfDM = ReportUtils.isSelfDM(report); | ||
let accountIDs = []; | ||
|
||
if (isSelfDM) { | ||
// For selfDM we need to add the currentUser as participants. | ||
accountIDs = [currentUserAccountID ?? 0]; | ||
} else { | ||
accountIDs = Object.keys(report.participants ?? {}).map(Number); | ||
if (ReportUtils.isOneOnOneChat(report)) { | ||
// For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants | ||
accountIDs = accountIDs.filter((accountID) => accountID !== currentUserAccountID); | ||
} | ||
} | ||
// For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants | ||
const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); | ||
const accountIDs = Object.keys(report.participants ?? {}) | ||
.map(Number) | ||
.filter((accountID) => accountID !== currentUserAccountID || !isOneOnOneChat); | ||
|
||
if (!accountIDs || accountIDs.length === 0) { | ||
return; | ||
|
@@ -1511,8 +1523,11 @@ function createOptionList(personalDetails: OnyxEntry<PersonalDetailsList>, repor | |
} | ||
|
||
function createOptionFromReport(report: Report, personalDetails: OnyxEntry<PersonalDetailsList>) { | ||
const isSelfDM = ReportUtils.isSelfDM(report); | ||
const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.participantAccountIDs ?? []; | ||
// For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants | ||
const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); | ||
const accountIDs = Object.keys(report.participants ?? {}) | ||
.map(Number) | ||
.filter((accountID) => accountID !== currentUserAccountID || !isOneOnOneChat); | ||
|
||
return { | ||
item: report, | ||
|
@@ -1768,18 +1783,12 @@ function getOptions( | |
const isPolicyExpenseChat = option.isPolicyExpenseChat; | ||
const isMoneyRequestReport = option.isMoneyRequestReport; | ||
const isSelfDM = option.isSelfDM; | ||
let accountIDs = []; | ||
|
||
if (isSelfDM) { | ||
// For selfDM we need to add the currentUser as participants. | ||
accountIDs = [currentUserAccountID ?? 0]; | ||
} else { | ||
accountIDs = Object.keys(report.participants ?? {}).map(Number); | ||
if (ReportUtils.isOneOnOneChat(report)) { | ||
// For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants | ||
accountIDs = accountIDs.filter((accountID) => accountID !== currentUserAccountID); | ||
} | ||
} | ||
const isOneOnOneChat = option.isOneOnOneChat; | ||
|
||
// For 1:1 chat, we don't want to include currentUser as participants in order to not mark 1:1 chats as having multiple participants | ||
const accountIDs = Object.keys(report.participants ?? {}) | ||
.map(Number) | ||
.filter((accountID) => accountID !== currentUserAccountID || !isOneOnOneChat); | ||
|
||
if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { | ||
return; | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.