Skip to content
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

Display latest reportName in all front end views with ReportUtils.getReportName #8569

Merged
merged 35 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
edfc7e6
Use latest name from Onyx in policyExpenseChats
Apr 8, 2022
2c273c3
Use policyExpenseChat title in HeaderView
Apr 14, 2022
ce6996b
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
Apr 14, 2022
0c5ecbe
Move function to avoid cyclic dependency
Apr 14, 2022
f79a573
Fix policyExpenseChat name in LHN
Apr 14, 2022
5038ade
Style fixes for whitespace and returntype
Apr 14, 2022
99a3f04
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
May 18, 2022
3579468
Fix import casing
May 18, 2022
9094517
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
May 18, 2022
e15c888
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
May 26, 2022
a7a15e1
Remove reportnamevaluepair check since reports in onyx don't have them
May 26, 2022
4730c25
Fix double #'ed chat room names
May 26, 2022
04e2db4
Fix blank report header view
May 26, 2022
1fa3974
Remove unused code
May 26, 2022
b3fa99a
Remove unecessary getPolicyExpenseChatTitle
May 27, 2022
1b89044
Use getReportName when building options
May 27, 2022
91e7646
Use getReportName in ReportDetailsPage
May 27, 2022
918a137
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
May 27, 2022
8920903
Use getReportName in ReportWelcomeText
May 27, 2022
9ab4d8d
Make tests accomodate Onyx Reports created from Report.getChatReportName
May 27, 2022
e5112f8
Remove redundant getChatReportName and put logic in getReportName
May 27, 2022
706be32
Update OptionListUtils test to use standard reportName in Onyx and po…
May 27, 2022
be133b7
Clean up tests slightly
May 27, 2022
850e647
Make function only relevant for chat reports
May 28, 2022
5442735
lint fixes
May 28, 2022
b953660
Use getReportName for all chat titles instead of doing double work
May 31, 2022
716dca0
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
May 31, 2022
3e495a2
Fix tests to work with name alphabetizing
Jun 1, 2022
aaefdf1
Fix tests for Captain Britain using personal detail
Jun 1, 2022
5493a37
Fix searching for options using reportName
Jun 1, 2022
9fd17a1
Lint fixes
Jun 1, 2022
150dfeb
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
Jun 1, 2022
e15edaa
Remove deleted translation which is no longer used
Jun 1, 2022
004b6d0
Fix policyExpenseChat tests
Jun 3, 2022
010ca12
Merge branch 'main' of github.com:Expensify/App into amal-policyExpen…
Jun 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const ReportWelcomeText = (props) => {
{roomWelcomeMessage.phrase1}
</Text>
<Text style={[styles.textStrong]} onPress={() => Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))}>
{props.report.reportName}
{ReportUtils.getReportName(props.report, props.personalDetails, props.policies)}
</Text>
<Text>
{roomWelcomeMessage.phrase2}
Expand Down
6 changes: 3 additions & 3 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ function createOption(logins, personalDetails, report, {
}) {
const isChatRoom = ReportUtils.isChatRoom(report);
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
const personalDetailList = _.values(getPersonalDetailsForLogins(logins, personalDetails));
const personalDetailMap = getPersonalDetailsForLogins(logins, personalDetails);
const personalDetailList = _.values(personalDetailMap);
const isArchivedRoom = ReportUtils.isArchivedRoom(report);
const hasMultipleParticipants = personalDetailList.length > 1 || isChatRoom || isPolicyExpenseChat;
const personalDetail = personalDetailList[0];
Expand Down Expand Up @@ -252,8 +253,7 @@ function createOption(logins, personalDetails, report, {
let text;
let alternateText;
if (isChatRoom || isPolicyExpenseChat) {
text = lodashGet(report, 'reportName')
|| lodashGet(report, 'oldPolicyName', '');
text = ReportUtils.getReportName(report, personalDetailMap, policies);
alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText)
? lastMessageText
: subtitle;
Expand Down
6 changes: 1 addition & 5 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,9 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport)
* @returns {String}
*/
function getReportName(report, personalDetailsForParticipants = {}, policies = {}) {
if (lodashGet(report, 'reportNameValuePairs.type') !== 'chat') {
return lodashGet(report, 'reportName', '');
}

let formattedName;
if (isChatRoom(report)) {
formattedName = `#${report.reportName}`;
formattedName = report.reportName;
}

if (isPolicyExpenseChat(report)) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ReportDetailsPage extends Component {
<View style={[styles.reportDetailsRoomInfo, styles.mw100]}>
<View style={[styles.alignSelfCenter, styles.w100]}>
<DisplayNames
fullTitle={this.props.report.reportName}
fullTitle={ReportUtils.getReportName(this.props.report, this.props.personalDetails, this.props.policies)}
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled
numberOfLines={1}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const HeaderView = (props) => {
</Pressable>
</Tooltip>
)}
{Boolean(props.report && props.report.reportName) && (
{Boolean(props.report && title) && (
<View
style={[
styles.flex1,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/ReportUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('ReportUtils', () => {
const baseAdminsRoom = {
...REPORT_TYPE_CHAT,
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS,
reportName: 'admins',
reportName: '#admins',
};

test('Active', () => {
Expand All @@ -157,7 +157,7 @@ describe('ReportUtils', () => {
const baseUserCreatedRoom = {
...REPORT_TYPE_CHAT,
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
reportName: 'VikingsChat',
reportName: '#VikingsChat',
};

test('Active', () => {
Expand Down