-
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
Check if policy room is archived because of merging #14779
Changes from all commits
07fc435
46c0c44
80d264f
5e06a1f
6036b74
aec314f
ba64ef9
680608c
829ac76
210068e
81cd5e9
6b541f1
9f305a8
2f2c0c2
9482f61
96753fb
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ import Navigation from './Navigation/Navigation'; | |
import ROUTES from '../ROUTES'; | ||
import * as NumberUtils from './NumberUtils'; | ||
import * as NumberFormatUtils from './NumberFormatUtils'; | ||
import * as ReportActionsUtils from './ReportActionsUtils'; | ||
import Permissions from './Permissions'; | ||
import DateUtils from './DateUtils'; | ||
import linkingConfig from './Navigation/linkingConfig'; | ||
|
@@ -72,7 +73,7 @@ let doesDomainHaveApprovedAccountant; | |
Onyx.connect({ | ||
key: ONYXKEYS.ACCOUNT, | ||
waitForCollectionCallback: true, | ||
callback: val => doesDomainHaveApprovedAccountant = val.doesDomainHaveApprovedAccountant, | ||
callback: val => doesDomainHaveApprovedAccountant = val.doesDomainHaveApprovedAccountant || false, | ||
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. I have been running to this value not being defined locally and causing the app not to load so casting this to false in case |
||
}); | ||
|
||
function getChatType(report) { | ||
|
@@ -654,6 +655,39 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) | |
}); | ||
} | ||
|
||
/** | ||
* Get the title for a policy expense chat which depends on the role of the policy member seeing this report | ||
* | ||
* @param {Object} report | ||
* @param {Object} [policies] | ||
* @returns {String} | ||
*/ | ||
function getPolicyExpenseChatName(report, policies = {}) { | ||
const reportOwnerDisplayName = getDisplayNameForParticipant(report.ownerEmail) || report.ownerEmail || report.reportName; | ||
|
||
// If the policy expense chat is owned by this user, use the name of the policy as the report name. | ||
if (report.isOwnPolicyExpenseChat) { | ||
return getPolicyName(report, policies); | ||
} | ||
|
||
const policyExpenseChatRole = lodashGet(policies, [ | ||
`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'role', | ||
]) || 'user'; | ||
|
||
// If this user is not admin and this policy expense chat has been archived because of account merging, this must be an old workspace chat | ||
// of the account which was merged into the current user's account. Use the name of the policy as the name of the report. | ||
if (isArchivedRoom(report)) { | ||
const lastAction = ReportActionsUtils.getLastVisibleAction(report.reportID); | ||
const archiveReason = (lastAction && lastAction.originalMessage && lastAction.originalMessage.reason) || CONST.REPORT.ARCHIVE_REASON.DEFAULT; | ||
if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED && policyExpenseChatRole !== CONST.POLICY.ROLE.ADMIN) { | ||
return getPolicyName(report, policies); | ||
} | ||
} | ||
|
||
// If user can see this report and they are not its owner, they must be an admin and the report name should be the name of the policy member | ||
return reportOwnerDisplayName; | ||
} | ||
|
||
/** | ||
* Get the title for a report. | ||
* | ||
|
@@ -668,8 +702,7 @@ function getReportName(report, policies = {}) { | |
} | ||
|
||
if (isPolicyExpenseChat(report)) { | ||
const reportOwnerDisplayName = getDisplayNameForParticipant(report.ownerEmail) || report.ownerEmail || report.reportName; | ||
formattedName = report.isOwnPolicyExpenseChat ? getPolicyName(report, policies) : reportOwnerDisplayName; | ||
formattedName = getPolicyExpenseChatName(report, policies); | ||
} | ||
|
||
if (isArchivedRoom(report)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import Tooltip from '../../../components/Tooltip'; | |
import ControlSelection from '../../../libs/ControlSelection'; | ||
import * as ReportUtils from '../../../libs/ReportUtils'; | ||
import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; | ||
import CONST from '../../../CONST'; | ||
|
||
const propTypes = { | ||
/** All the data of the action */ | ||
|
@@ -51,13 +52,14 @@ const showUserDetails = (email) => { | |
}; | ||
|
||
const ReportActionItemSingle = (props) => { | ||
const actorEmail = props.action.actorEmail.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); | ||
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 directly related, but we should have created a utility function that did this replacement. Later on, at some places we forgot to do this replacement which caused #32127. |
||
const { | ||
avatar, | ||
displayName, | ||
login, | ||
pendingFields, | ||
} = props.personalDetails[props.action.actorEmail] || {}; | ||
const avatarSource = ReportUtils.getAvatar(avatar, props.action.actorEmail); | ||
} = props.personalDetails[actorEmail] || {}; | ||
const avatarSource = ReportUtils.getAvatar(avatar, actorEmail); | ||
|
||
// Since the display name for a report action message is delivered with the report history as an array of fragments | ||
// we'll need to take the displayName from personal details and have it be in the same format for now. Eventually, | ||
|
@@ -72,9 +74,9 @@ const ReportActionItemSingle = (props) => { | |
style={[styles.alignSelfStart, styles.mr3]} | ||
onPressIn={ControlSelection.block} | ||
onPressOut={ControlSelection.unblock} | ||
onPress={() => showUserDetails(props.action.actorEmail)} | ||
onPress={() => showUserDetails(actorEmail)} | ||
> | ||
<Tooltip text={props.action.actorEmail}> | ||
<Tooltip text={actorEmail}> | ||
<OfflineWithFeedback | ||
pendingAction={lodashGet(pendingFields, 'avatar', null)} | ||
> | ||
|
@@ -92,13 +94,13 @@ const ReportActionItemSingle = (props) => { | |
style={[styles.flexShrink1, styles.mr1]} | ||
onPressIn={ControlSelection.block} | ||
onPressOut={ControlSelection.unblock} | ||
onPress={() => showUserDetails(props.action.actorEmail)} | ||
onPress={() => showUserDetails(actorEmail)} | ||
> | ||
{_.map(personArray, (fragment, index) => ( | ||
<ReportActionItemFragment | ||
key={`person-${props.action.reportActionID}-${index}`} | ||
fragment={fragment} | ||
tooltipText={props.action.actorEmail} | ||
tooltipText={actorEmail} | ||
isAttachment={props.action.isAttachment} | ||
isLoading={props.action.isLoading} | ||
isSingleLine | ||
|
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 is to resolve a cyclic dependency between these two utility libraries