From b1bf1c93f004599d30f4ad200396230f5af61a57 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Sat, 8 Jul 2023 10:50:18 +0100 Subject: [PATCH 01/11] Match LHN and Report Header Avatars --- src/components/AvatarWithDisplayName.js | 16 ++++++++-------- src/libs/ReportUtils.js | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/AvatarWithDisplayName.js b/src/components/AvatarWithDisplayName.js index f63b51cacf99..1f2462374cf2 100644 --- a/src/components/AvatarWithDisplayName.js +++ b/src/components/AvatarWithDisplayName.js @@ -12,6 +12,7 @@ import themeColors from '../styles/themes/default'; import SubscriptAvatar from './SubscriptAvatar'; import * as ReportUtils from '../libs/ReportUtils'; import Avatar from './Avatar'; +import MultipleAvatars from './MultipleAvatars'; import DisplayNames from './DisplayNames'; import compose from '../libs/compose'; import * as OptionsListUtils from '../libs/OptionsListUtils'; @@ -60,12 +61,12 @@ function AvatarWithDisplayName(props) { const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies); const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails); const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(_.values(ownerPersonalDetails), false); - const avatarContainerStyle = StyleUtils.getEmptyAvatarStyle(props.size) || styles.emptyAvatar; + const shouldShowSubscriptAvatar = ReportUtils.shouldReportShowSubscript(props.report); return ( {Boolean(props.report && title) && ( - {isExpenseReport ? ( + {shouldShowSubscriptAvatar ? ( ) : ( - )} - + Date: Sat, 8 Jul 2023 10:53:10 +0100 Subject: [PATCH 02/11] Clean up --- src/components/AvatarWithDisplayName.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/AvatarWithDisplayName.js b/src/components/AvatarWithDisplayName.js index 1f2462374cf2..4a2be3e1f326 100644 --- a/src/components/AvatarWithDisplayName.js +++ b/src/components/AvatarWithDisplayName.js @@ -11,7 +11,6 @@ import styles from '../styles/styles'; import themeColors from '../styles/themes/default'; import SubscriptAvatar from './SubscriptAvatar'; import * as ReportUtils from '../libs/ReportUtils'; -import Avatar from './Avatar'; import MultipleAvatars from './MultipleAvatars'; import DisplayNames from './DisplayNames'; import compose from '../libs/compose'; @@ -77,8 +76,7 @@ function AvatarWithDisplayName(props) { )} From 4bef0f30e23dc6a6c0d9b41bae6aff7134d5a2bc Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Sat, 8 Jul 2023 11:05:25 +0100 Subject: [PATCH 03/11] Match to optionUtils --- src/components/AvatarWithDisplayName.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AvatarWithDisplayName.js b/src/components/AvatarWithDisplayName.js index 4a2be3e1f326..fc82a534f9a0 100644 --- a/src/components/AvatarWithDisplayName.js +++ b/src/components/AvatarWithDisplayName.js @@ -57,7 +57,7 @@ function AvatarWithDisplayName(props) { const subtitle = ReportUtils.getChatRoomSubtitle(props.report); const parentNavigationSubtitle = ReportUtils.getParentNavigationSubtitle(props.report); const isExpenseReport = ReportUtils.isExpenseReport(props.report); - const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies); + const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies, true); const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails); const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(_.values(ownerPersonalDetails), false); const shouldShowSubscriptAvatar = ReportUtils.shouldReportShowSubscript(props.report); From f20a775f7103698285bb4bbaa3735c7d5d9878db Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Sat, 8 Jul 2023 11:15:26 +0100 Subject: [PATCH 04/11] Fix expense request --- src/components/AvatarWithDisplayName.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/AvatarWithDisplayName.js b/src/components/AvatarWithDisplayName.js index fc82a534f9a0..cea5eb674508 100644 --- a/src/components/AvatarWithDisplayName.js +++ b/src/components/AvatarWithDisplayName.js @@ -61,6 +61,8 @@ function AvatarWithDisplayName(props) { const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails); const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(_.values(ownerPersonalDetails), false); const shouldShowSubscriptAvatar = ReportUtils.shouldReportShowSubscript(props.report); + const isExpenseRequest = ReportUtils.isExpenseRequest(props.report); + const defaultSubscriptSize = isExpenseRequest ? CONST.AVATAR_SIZE.SMALL_NORMAL : props.size; return ( {Boolean(props.report && title) && ( @@ -70,7 +72,7 @@ function AvatarWithDisplayName(props) { backgroundColor={themeColors.highlightBG} mainAvatar={icons[0]} secondaryAvatar={icons[1]} - size={props.size} + size={defaultSubscriptSize} /> ) : ( )} - + Date: Mon, 24 Jul 2023 12:55:41 +0100 Subject: [PATCH 05/11] Fix header view --- src/pages/home/ReportScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 5d825a528bdf..be52da5f1f1f 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -266,7 +266,7 @@ class ReportScreen extends React.Component { this.firstRenderRef.current = false; const parentReportAction = ReportActionsUtils.getParentReportAction(this.props.report); - const isSingleTransactionView = ReportActionsUtils.isTransactionThread(parentReportAction); + const isSingleTransactionView = ReportUtils.isMoneyRequestReport(this.props.report); const policy = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`]; From 4feba7fad0fabdb58c12eaacb5cff18c33f39d6d Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 24 Jul 2023 14:18:10 +0100 Subject: [PATCH 06/11] Bug fixes --- src/libs/ReportUtils.js | 60 +++++++++++++++++++++++++--------- src/pages/home/ReportScreen.js | 2 +- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 470ea60b2464..240384870800 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -182,17 +182,6 @@ function isTaskAssignee(report) { return lodashGet(report, 'managerID') === currentUserAccountID; } -/** - * Checks if a report is an IOU or expense report. - * - * @param {Object|String} reportOrID - * @returns {Boolean} - */ -function isMoneyRequestReport(reportOrID) { - const report = _.isObject(reportOrID) ? reportOrID : allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportOrID}`]; - return isIOUReport(report) || isExpenseReport(report); -} - /** * Given a collection of reports returns them sorted by last read * @@ -634,6 +623,44 @@ function isExpenseRequest(report) { return false; } +/** + * An IOU Request is a thread where the parent report is an IOU Report and + * the parentReportAction is a transaction. + * + * @param {Object} report + * @returns {Boolean} + */ +function isIOURequest(report) { + if (isThread(report)) { + const parentReportAction = ReportActionsUtils.getParentReportAction(report); + const parentReport = lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`]); + return isIOUReport(parentReport) && ReportActionsUtils.isTransactionThread(parentReportAction); + } + return false; +} + +/** + * Checks if a report is an IOU or expense request. + * + * @param {Object|String} reportOrID + * @returns {Boolean} + */ +function isMoneyRequest(reportOrID) { + const report = _.isObject(reportOrID) ? reportOrID : allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportOrID}`]; + return isIOURequest(report) || isExpenseRequest(report); +} + +/** + * Checks if a report is an IOU or expense report. + * + * @param {Object|String} reportOrID + * @returns {Boolean} + */ +function isMoneyRequestReport(reportOrID) { + const report = _.isObject(reportOrID) ? reportOrID : allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportOrID}`]; + return isIOUReport(report) || isExpenseReport(report); +} + /** * Get welcome message based on room type * @param {Object} report @@ -1190,12 +1217,12 @@ function getRootReportAndWorkspaceName(report) { return getRootReportAndWorkspaceName(parentReport); } - if (isIOUReport(report)) { + if (isIOURequest(report)) { return { rootReportName: lodashGet(report, 'displayName', ''), }; } - if (isMoneyRequestReport(report)) { + if (isExpenseRequest(report)) { return { rootReportName: lodashGet(report, 'displayName', ''), workspaceName: isIOUReport(report) ? CONST.POLICY.OWNER_EMAIL_FAKE : getPolicyName(report, true), @@ -2505,9 +2532,9 @@ function shouldReportShowSubscript(report) { return false; } - if (isMoneyRequestReport(report)) { - return false; - } + // if (isMoneyRequestReport(report)) { + // return false; + // } if (isPolicyExpenseChat(report) && !isChatThread(report) && !isTaskReport(report) && !report.isOwnPolicyExpenseChat) { return true; @@ -2704,6 +2731,7 @@ export { isCompletedTaskReport, isTaskAssignee, isMoneyRequestReport, + isMoneyRequest, chatIncludesChronos, getNewMarkerReportActionID, canSeeDefaultRoom, diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index be52da5f1f1f..e8c70635fdf9 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -266,7 +266,7 @@ class ReportScreen extends React.Component { this.firstRenderRef.current = false; const parentReportAction = ReportActionsUtils.getParentReportAction(this.props.report); - const isSingleTransactionView = ReportUtils.isMoneyRequestReport(this.props.report); + const isSingleTransactionView = ReportUtils.isMoneyRequest(this.props.report); const policy = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`]; From 56b53563d5d76983c5fa4b5c51c4ccdfce0cf6b8 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 24 Jul 2023 15:19:23 +0100 Subject: [PATCH 07/11] Match LHN Title / Subtitle to Header --- src/components/AvatarWithDisplayName.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/AvatarWithDisplayName.js b/src/components/AvatarWithDisplayName.js index e5431696ba2a..b2644ab0eef9 100644 --- a/src/components/AvatarWithDisplayName.js +++ b/src/components/AvatarWithDisplayName.js @@ -53,10 +53,10 @@ const defaultProps = { }; function AvatarWithDisplayName(props) { - const title = props.isAnonymous ? ReportUtils.getReportName(props.report) : ReportUtils.getDisplayNameForParticipant(props.report.ownerAccountID, true); + const title = ReportUtils.getReportName(props.report); const subtitle = ReportUtils.getChatRoomSubtitle(props.report); const parentNavigationSubtitle = ReportUtils.getParentNavigationSubtitle(props.report); - const isExpenseReport = ReportUtils.isExpenseReport(props.report); + const isMoneyRequestOrReport = ReportUtils.isMoneyRequestReport(props.report) || ReportUtils.isMoneyRequest(props.report); const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies, true); const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails); const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(_.values(ownerPersonalDetails), false); @@ -88,7 +88,7 @@ function AvatarWithDisplayName(props) { tooltipEnabled numberOfLines={1} textStyles={[props.isAnonymous ? styles.headerAnonymousFooter : styles.headerText, styles.pre]} - shouldUseFullTitle={isExpenseReport || props.isAnonymous} + shouldUseFullTitle={isMoneyRequestOrReport || props.isAnonymous} /> {!_.isEmpty(parentNavigationSubtitle) && ( Date: Tue, 25 Jul 2023 18:59:26 +0100 Subject: [PATCH 08/11] remove comment --- src/libs/ReportUtils.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 1b3b15ca495a..b34842790695 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2543,10 +2543,6 @@ function shouldReportShowSubscript(report) { return false; } - // if (isMoneyRequestReport(report)) { - // return false; - // } - if (isPolicyExpenseChat(report) && !isChatThread(report) && !isTaskReport(report) && !report.isOwnPolicyExpenseChat) { return true; } From 3c2fa2a00d4f98ce2aaca3af571fb4e98854b4b3 Mon Sep 17 00:00:00 2001 From: Georgia Monahan <38015950+grgia@users.noreply.github.com> Date: Tue, 25 Jul 2023 18:59:58 +0100 Subject: [PATCH 09/11] Update src/libs/ReportUtils.js Co-authored-by: Rajat Parashar --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index b34842790695..43a3dc1b137f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -643,7 +643,7 @@ function isExpenseRequest(report) { function isIOURequest(report) { if (isThread(report)) { const parentReportAction = ReportActionsUtils.getParentReportAction(report); - const parentReport = lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`]); + const parentReport = allReports[`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`]; return isIOUReport(parentReport) && ReportActionsUtils.isTransactionThread(parentReportAction); } return false; From 8c2f618bc8775f5a68dbaed2d2fb31675054cccd Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Wed, 26 Jul 2023 09:08:21 +0100 Subject: [PATCH 10/11] fix subscript expenseRequest borderRadius bug --- src/components/SubscriptAvatar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/SubscriptAvatar.js b/src/components/SubscriptAvatar.js index 64faafc0ba3e..1c6f0a38c3d0 100644 --- a/src/components/SubscriptAvatar.js +++ b/src/components/SubscriptAvatar.js @@ -55,6 +55,7 @@ function SubscriptAvatar(props) { > Date: Fri, 28 Jul 2023 16:51:57 +0100 Subject: [PATCH 11/11] remove color style --- src/components/SubscriptAvatar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SubscriptAvatar.js b/src/components/SubscriptAvatar.js index 1c6f0a38c3d0..05202e720bd4 100644 --- a/src/components/SubscriptAvatar.js +++ b/src/components/SubscriptAvatar.js @@ -55,7 +55,7 @@ function SubscriptAvatar(props) { >