Skip to content

Commit c5cfe64

Browse files
committed
disable go to profile page for optimistic user
1 parent ba08d3d commit c5cfe64

File tree

8 files changed

+35
-10
lines changed

8 files changed

+35
-10
lines changed

src/components/MoneyRequestConfirmationList.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import {withOnyx} from 'react-native-onyx';
44
import _ from 'underscore';
55
import styles from '../styles/styles';
6+
import * as ReportUtils from '../libs/ReportUtils';
67
import * as OptionsListUtils from '../libs/OptionsListUtils';
78
import OptionsSelector from './OptionsSelector';
89
import ONYXKEYS from '../ONYXKEYS';
@@ -164,9 +165,13 @@ function MoneyRequestConfirmationList(props) {
164165
},
165166
);
166167
} else {
168+
const formattedSelectedParticipants = _.map(props.selectedParticipants, (participant) => ({
169+
...participant,
170+
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID),
171+
}));
167172
sections.push({
168173
title: translate('common.to'),
169-
data: props.selectedParticipants,
174+
data: formattedSelectedParticipants,
170175
shouldShow: true,
171176
indexOffset: 0,
172177
});

src/components/OptionsList/BaseOptionsList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class BaseOptionsList extends Component {
160160
* @return {Component}
161161
*/
162162
renderItem({item, index, section}) {
163-
const isDisabled = this.props.isDisabled || section.isDisabled;
163+
const isDisabled = this.props.isDisabled || section.isDisabled || !!item.isDisabled;
164164
return (
165165
<OptionRow
166166
option={item}

src/components/ReportWelcomeText.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,16 @@ function ReportWelcomeText(props) {
9999
{_.map(displayNamesWithTooltips, ({displayName, pronouns, accountID}, index) => (
100100
<Text key={`${displayName}${pronouns}${index}`}>
101101
<UserDetailsTooltip accountID={accountID}>
102-
<Text
103-
style={[styles.textStrong]}
104-
onPress={() => Navigation.navigate(ROUTES.getProfileRoute(accountID))}
105-
>
106-
{displayName}
107-
</Text>
102+
{ReportUtils.isOptimisticPersonalDetail(accountID) ? (
103+
<Text style={[styles.textStrong]}>{displayName}</Text>
104+
) : (
105+
<Text
106+
style={[styles.textStrong]}
107+
onPress={() => Navigation.navigate(ROUTES.getProfileRoute(accountID))}
108+
>
109+
{displayName}
110+
</Text>
111+
)}
108112
</UserDetailsTooltip>
109113
{!_.isEmpty(pronouns) && <Text>{` (${pronouns})`}</Text>}
110114
{index === displayNamesWithTooltips.length - 1 && <Text>.</Text>}

src/libs/OptionsListUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ function getIOUConfirmationOptionsFromParticipants(participants, amountText) {
920920
return _.map(participants, (participant) => ({
921921
...participant,
922922
descriptiveText: amountText,
923+
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID),
923924
}));
924925
}
925926

src/libs/ReportUtils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,15 @@ function getBankAccountRoute(report) {
403403
return isPolicyExpenseChat(report) ? ROUTES.getBankAccountRoute('', report.policyID) : ROUTES.SETTINGS_ADD_BANK_ACCOUNT;
404404
}
405405

406+
/**
407+
* Check if personal detail of accountID is empty or optimistic data
408+
* @param {String} accountID user accountID
409+
* @returns {Boolean}
410+
*/
411+
function isOptimisticPersonalDetail(accountID) {
412+
return _.isEmpty(allPersonalDetails[accountID]) || !!allPersonalDetails[accountID].isOptimisticPersonalDetail;
413+
}
414+
406415
/**
407416
* Checks if a report is a task report from a policy expense chat.
408417
*
@@ -2841,6 +2850,7 @@ export {
28412850
getAllPolicyReports,
28422851
getIOUReportActionMessage,
28432852
getDisplayNameForParticipant,
2853+
isOptimisticPersonalDetail,
28442854
isChatReport,
28452855
isCurrentUserSubmitter,
28462856
isExpenseReport,

src/libs/actions/Report.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ function openReport(reportID, participantLoginList = [], newReportObject = {}, p
475475
accountID,
476476
avatar: UserUtils.getDefaultAvatarURL(accountID),
477477
displayName: login,
478+
isOptimisticPersonalDetail: true,
478479
};
479480

480481
failurePersonalDetails[accountID] = allPersonalDetails[accountID] || null;

src/pages/ReportParticipantsPage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ const getAllParticipants = (report, personalDetails, translate) => {
8686
};
8787

8888
function ReportParticipantsPage(props) {
89-
const participants = getAllParticipants(props.report, props.personalDetails, props.translate);
89+
const participants = _.map(getAllParticipants(props.report, props.personalDetails, props.translate), (participant) => ({
90+
...participant,
91+
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID),
92+
}));
9093

9194
return (
9295
<ScreenWrapper includeSafeAreaPaddingBottom={false}>

src/pages/home/HeaderView.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function HeaderView(props) {
134134
const icons = ReportUtils.getIcons(reportHeaderData, props.personalDetails);
135135
const brickRoadIndicator = ReportUtils.hasReportNameError(props.report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';
136136
const shouldShowBorderBottom = !isTaskReport || !props.isSmallScreenWidth;
137+
const isOptimisticDetail = !isMultipleParticipant && ReportUtils.isOptimisticPersonalDetail(participants[0]) && !props.report.parentReportID;
137138

138139
return (
139140
<View
@@ -164,7 +165,7 @@ function HeaderView(props) {
164165
<PressableWithoutFeedback
165166
onPress={() => ReportUtils.navigateToDetailsPage(props.report)}
166167
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}
167-
disabled={isTaskReport && !ReportUtils.isOpenTaskReport(props.report)}
168+
disabled={(isTaskReport && !ReportUtils.isOpenTaskReport(props.report)) || isOptimisticDetail}
168169
accessibilityLabel={title}
169170
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
170171
>

0 commit comments

Comments
 (0)