Repository navigation
Adapt Split Bill to workspace chats #24058
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1393162
Enable split bill option for Control workspace chats
36e7559
Adapt splitBill to workspace chats
9c65035
Fix a few bugs
4e80915
Merge branch 'main' into youssef_splitbill_workspace
88c4103
Display participants properly in IOUPreview and split details page
11cfc57
Merge branch 'main' into youssef_splitbill_workspace
b263083
Merge branch 'main' into youssef_splitbill_workspace
bb292bd
Fix details page crashing
db31687
Fix undefined participant added to to split bill participants
0a74516
Bug fix
56a0cdd
Fix linting
7caef45
Remove IOUReportID for split actions from workspace
02bfc43
Merge branch 'main' into youssef_splitbill_workspace
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 hidden or 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 hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -323,6 +323,17 @@ function isUserCreatedPolicyRoom(report) { | |||||
| return getChatType(report) === CONST.REPORT.CHAT_TYPE.POLICY_ROOM; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Get the policy type from a given report | ||||||
| * @param {Object} report | ||||||
| * @param {String} report.policyID | ||||||
| * @param {Object} policies must have Onyxkey prefix (i.e 'policy_') for keys | ||||||
| * @returns {String} | ||||||
| */ | ||||||
| function getPolicyType(report, policies) { | ||||||
| return lodashGet(policies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'type'], ''); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Whether the provided report is a Policy Expense chat. | ||||||
| * @param {Object} report | ||||||
|
|
@@ -333,6 +344,22 @@ function isPolicyExpenseChat(report) { | |||||
| return getChatType(report) === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT; | ||||||
| } | ||||||
|
|
||||||
| /** Wether the provided report belongs to a Control policy and is an epxense chat | ||||||
| * @param {Object} report | ||||||
| * @returns {Boolean} | ||||||
| */ | ||||||
| function isControlPolicyExpenseChat(report) { | ||||||
| return isPolicyExpenseChat(report) && getPolicyType(report, allPolicies) === CONST.POLICY.TYPE.CORPORATE; | ||||||
| } | ||||||
|
|
||||||
| /** Wether the provided report belongs to a Control policy and is an epxense report | ||||||
| * @param {Object} report | ||||||
| * @returns {Boolean} | ||||||
| */ | ||||||
| function isControlPolicyExpenseReport(report) { | ||||||
| return isExpenseReport(report) && getPolicyType(report, allPolicies) === CONST.POLICY.TYPE.CORPORATE; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Whether the provided report is a chat room | ||||||
| * @param {Object} report | ||||||
|
|
@@ -365,17 +392,6 @@ function isPublicAnnounceRoom(report) { | |||||
| return visibility === CONST.REPORT.VISIBILITY.PUBLIC_ANNOUNCE; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
youssef-lr marked this conversation as resolved.
Resolved
|
||||||
| * Get the policy type from a given report | ||||||
| * @param {Object} report | ||||||
| * @param {String} report.policyID | ||||||
| * @param {Object} policies must have Onyxkey prefix (i.e 'policy_') for keys | ||||||
| * @returns {String} | ||||||
| */ | ||||||
| function getPolicyType(report, policies) { | ||||||
| return lodashGet(policies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'type'], ''); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * If the report is a policy expense, the route should be for adding bank account for that policy | ||||||
| * else since the report is a personal IOU, the route should be for personal bank account. | ||||||
|
|
@@ -1852,6 +1868,7 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType = | |||||
| * @param {Boolean} [isSettlingUp] - Whether we are settling up an IOU. | ||||||
| * @param {Boolean} [isSendMoneyFlow] - Whether this is send money flow | ||||||
| * @param {Object} [receipt] | ||||||
| * @param {Boolean} [isOwnPolicyExpenseChat] - Whether this is an expense report create from the current user's policy expense chat | ||||||
|
Contributor
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.
Suggested change
Nitpicking here! |
||||||
| * @returns {Object} | ||||||
| */ | ||||||
| function buildOptimisticIOUReportAction( | ||||||
|
|
@@ -1866,6 +1883,7 @@ function buildOptimisticIOUReportAction( | |||||
| isSettlingUp = false, | ||||||
| isSendMoneyFlow = false, | ||||||
| receipt = {}, | ||||||
| isOwnPolicyExpenseChat = false, | ||||||
| ) { | ||||||
| const IOUReportID = iouReportID || generateReportID(); | ||||||
|
|
||||||
|
|
@@ -1898,7 +1916,12 @@ function buildOptimisticIOUReportAction( | |||||
| // IOUs of type split only exist in group DMs and those don't have an iouReport so we need to delete the IOUReportID key | ||||||
| if (type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT) { | ||||||
| delete originalMessage.IOUReportID; | ||||||
| originalMessage.participantAccountIDs = [currentUserAccountID, ..._.pluck(participants, 'accountID')]; | ||||||
| // Split bill made from a policy expense chat only have the payee's accountID as the participant because the payer could be any policy admin | ||||||
| if (isOwnPolicyExpenseChat) { | ||||||
| originalMessage.participantAccountIDs = [currentUserAccountID]; | ||||||
| } else { | ||||||
| originalMessage.participantAccountIDs = [currentUserAccountID, ..._.pluck(participants, 'accountID')]; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| return { | ||||||
|
|
@@ -2796,7 +2819,7 @@ function getMoneyRequestOptions(report, reportParticipants, betas) { | |||||
| // unless there are no participants at all (e.g. #admins room for a policy with only 1 admin) | ||||||
| // DM chats will have the Split Bill option only when there are at least 3 people in the chat. | ||||||
| // There is no Split Bill option for Workspace chats | ||||||
| if (isChatRoom(report) || (hasMultipleParticipants && !isPolicyExpenseChat(report))) { | ||||||
| if (isChatRoom(report) || (hasMultipleParticipants && !isPolicyExpenseChat(report)) || isControlPolicyExpenseChat(report)) { | ||||||
| return [CONST.IOU.MONEY_REQUEST_TYPE.SPLIT]; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -3171,6 +3194,8 @@ export { | |||||
| formatReportLastMessageText, | ||||||
| chatIncludesConcierge, | ||||||
| isPolicyExpenseChat, | ||||||
| isControlPolicyExpenseChat, | ||||||
| isControlPolicyExpenseReport, | ||||||
| getIconsForParticipants, | ||||||
| getIcons, | ||||||
| getRoomWelcomeMessage, | ||||||
|
|
@@ -3208,6 +3233,7 @@ export { | |||||
| getAllPolicyReports, | ||||||
| getIOUReportActionMessage, | ||||||
| getDisplayNameForParticipant, | ||||||
| getWorkspaceIcon, | ||||||
| isOptimisticPersonalDetail, | ||||||
| shouldDisableDetailPage, | ||||||
| isChatReport, | ||||||
|
|
||||||
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.
I think we should add this
chatReportto thepropTypesanddefaultProps