-
Notifications
You must be signed in to change notification settings - Fork 4k
Workspaces in money request modal #17132
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
Changes from all commits
1d602e4
bddf4b0
80efa65
22f6234
964c5ce
b31fb44
1d9f7be
bb95eae
dd7da6a
ca7d9c7
13ff8e3
b1654c5
54e5be9
c59279a
ba9741a
33969d7
fcda6a8
3c9ebb2
e813f18
a42f122
f5aa96e
37e7740
b3e2660
3278622
c200d93
41b9d74
ffd15bf
4f995a9
9754a32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| import _ from 'underscore'; | ||
| import Onyx from 'react-native-onyx'; | ||
| import lodashOrderBy from 'lodash/orderBy'; | ||
| import lodashGet from 'lodash/get'; | ||
| import Str from 'expensify-common/lib/str'; | ||
| import ONYXKEYS from '../ONYXKEYS'; | ||
| import CONST from '../CONST'; | ||
|
|
@@ -77,6 +78,45 @@ Onyx.connect({ | |
| }, | ||
| }); | ||
|
|
||
| const policyExpenseReports = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT, | ||
| callback: (report, key) => { | ||
| if (!ReportUtils.isPolicyExpenseChat(report)) { | ||
| return; | ||
| } | ||
| policyExpenseReports[key] = report; | ||
| }, | ||
| }); | ||
|
luacmartins marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Get the options for a policy expense report. | ||
| * @param {Object} report | ||
| * @returns {Array} | ||
| */ | ||
| function getPolicyExpenseReportOptions(report) { | ||
|
cristipaval marked this conversation as resolved.
|
||
| if (!ReportUtils.isPolicyExpenseChat(report)) { | ||
| return []; | ||
| } | ||
| const filteredPolicyExpenseReports = _.filter(policyExpenseReports, policyExpenseReport => policyExpenseReport.policyID === report.policyID); | ||
| return _.map(filteredPolicyExpenseReports, (expenseReport) => { | ||
| const policyExpenseChatAvatarSource = lodashGet(policies, [ | ||
| `${ONYXKEYS.COLLECTION.POLICY}${expenseReport.policyID}`, 'avatar', | ||
| ]) || ReportUtils.getDefaultWorkspaceAvatar(expenseReport.displayName); | ||
| return { | ||
| ...expenseReport, | ||
|
cristipaval marked this conversation as resolved.
|
||
| keyForList: expenseReport.policyID, | ||
| text: expenseReport.displayName, | ||
|
Member
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. Not exactly a regression but we shouldn't have used This worked fine with money request because you are the only one who can see the participants list (and that's only at the creation phase). But that's not the case with split action. |
||
| alternateText: Localize.translateLocal('workspace.common.workspace'), | ||
| icons: [{ | ||
| source: policyExpenseChatAvatarSource, | ||
| name: expenseReport.displayName, | ||
| type: CONST.ICON_TYPE_WORKSPACE, | ||
| }], | ||
|
Comment on lines
+111
to
+115
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. We should have used the already existing |
||
| }; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Adds expensify SMS domain (@expensify.sms) if login is a phone number and if it's not included yet | ||
| * | ||
|
|
@@ -126,6 +166,31 @@ function getPersonalDetailsForLogins(logins, personalDetails) { | |
| return personalDetailsForLogins; | ||
| } | ||
|
|
||
| /** | ||
| * Get the participant options for a report. | ||
| * @param {Object} report | ||
| * @param {Array<Object>} personalDetails | ||
| * @returns {Array} | ||
| */ | ||
| function getParticipantsOptions(report, personalDetails) { | ||
|
cristipaval marked this conversation as resolved.
|
||
| const participants = lodashGet(report, 'participants', []); | ||
| return _.map(getPersonalDetailsForLogins(participants, personalDetails), details => ({ | ||
| keyForList: details.login, | ||
| login: details.login, | ||
| text: details.displayName, | ||
| firstName: lodashGet(details, 'firstName', ''), | ||
| lastName: lodashGet(details, 'lastName', ''), | ||
| alternateText: Str.isSMSLogin(details.login) ? Str.removeSMSDomain(details.login) : details.login, | ||
| icons: [{ | ||
| source: ReportUtils.getAvatar(details.avatar, details.login), | ||
| name: details.login, | ||
| type: CONST.ICON_TYPE_AVATAR, | ||
| }], | ||
| payPalMeAddress: lodashGet(details, 'payPalMeAddress', ''), | ||
| phoneNumber: lodashGet(details, 'phoneNumber', ''), | ||
| })); | ||
|
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. Just wondering: Any reason we didn't add
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. Maybe because of the split case, since those don't create an IOU/Expense report for the group 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. innnnnnnnnnnnnnnnnnnnnnnteresting that would make sense :D |
||
| } | ||
|
|
||
| /** | ||
| * Constructs a Set with all possible names (displayName, firstName, lastName, email) for all participants in a report, | ||
| * to be used in isSearchStringMatch. | ||
|
|
@@ -819,4 +884,6 @@ export { | |
| getIOUConfirmationOptionsFromParticipants, | ||
| getSearchText, | ||
| getAllReportErrors, | ||
| getPolicyExpenseReportOptions, | ||
| getParticipantsOptions, | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.