-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
New Thread Report Empty State, Header, LHN, OpenReport, Buttons for DEV #18522
Merged
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
7265063
Add new param for parentReportID
stitesExpensify c33c504
Add new params for threads, and build different optimisticData
stitesExpensify 8f641d4
Add new method for threads and revert old method
stitesExpensify 129cb0e
Update openReport to support threads
stitesExpensify 10a1729
Don't find threads when finding reports by participants
stitesExpensify 1333574
Add the 'reply in thread' button
stitesExpensify 22f561d
Fix logic and correctly pass reportActionID
stitesExpensify 0aacb49
Fix reportActions type
stitesExpensify 0c9ed14
Remove test vars
stitesExpensify 7e347d3
Merge branch 'main' into stites-updateOpenReportForThreads
grgia 7436a46
Merge branch 'main' into stites-updateOpenReportForThreads
grgia 4266c41
Hardcoded New Thread Report
grgia 1410cff
Add empty state for threads
grgia 1146e62
Fix reportActions type, dev comments
grgia 021ee2e
Fix LHN name (will work when reportName data is the parent message)
grgia fffd148
This is where we will set the LHN header to the parent message
grgia af69c87
Show header and subtitle for threads (hard coded)
grgia d997131
icons
grgia 4918794
icons cont
grgia 1863c6e
icons cont
grgia 18087c7
Update Empty State
grgia 5f35afb
Clean up icons
grgia a580293
Merge branch 'main' into georgia-ThreadReportUI
grgia ec85280
Remove comments
grgia b938973
Clean up
grgia 6f9e323
Clean up
grgia 48f1445
Merge branch 'main' into georgia-ThreadReportUI
grgia 9b1884a
Only show button in DEV environment
grgia 91eb65f
Clean up comments, update helper function deescriptions
grgia 2092286
clean up ReportActionItemParentAction props
grgia 23d0703
Remove console statement
grgia 6bbca5f
supply parentReportID to ReportActionItemParentAction
grgia cd3b78f
Fix opening child report for already created thread
grgia b4f5c03
Merge branch 'main' into georgia-ThreadReportUI
grgia 567dac6
default childReportID to string
grgia 7199670
Prevent deleting thread parents for now.
grgia 214bc12
spacing
grgia 48e02ed
Merge branch 'main' into georgia-ThreadReportUI
grgia 7a48a56
prettier
grgia b5013f7
Remove threads from search for users
grgia cd90b12
Fix threads UI in search bar
grgia 2ef1e03
Refactor getParentReportAction, update language key
grgia cc91bda
Remove unnecessary lodashGet, clean code
grgia d05b4a5
Use getReportName for title
grgia 896c317
Refactor to fix import/no-cycle
grgia 8957ff2
Merge branch 'main' into georgia-ThreadReportUI
grgia 9f44675
Show deleted parentActions
grgia f6055f9
Merge branch 'main' into georgia-ThreadReportUI
grgia 0752bd4
Remove childReportID
grgia 5227c01
Merge branch 'main' into georgia-ThreadReportUI
grgia bbd9ac4
Merge branch 'main' of github.com:Expensify/App into georgia-ThreadRe…
stitesExpensify 88e0ca5
fix workspace icon bug
grgia d89ac1c
Missed one line to fix icon
grgia 4210c7c
Merge branch 'georgia-ThreadReportUI' of github.com:Expensify/App int…
stitesExpensify 8d2ec3f
Merge branch 'main' of github.com:Expensify/App into georgia-ThreadRe…
stitesExpensify 9a815ca
Add beta check to threads
stitesExpensify 6effecb
Style
stitesExpensify 3a659c1
Don't show thread button for the parent comment
stitesExpensify 81a3d59
If the report is a task, pass the parent
stitesExpensify a3f17f2
Check for undefined because not all actions have a childReportID
stitesExpensify 074e5b2
Style
stitesExpensify e59c020
Remove newlines from headerText
grgia ec3fe30
fix lint errors
grgia 0e5e7e2
Use sentence casing (slack convo)
grgia ddb9185
Show threads in lhn regardles of number of participants
stitesExpensify bd091a9
Merge branch 'main' of github.com:Expensify/App into georgia-ThreadRe…
stitesExpensify 3396611
Merge branch 'georgia-ThreadReportUI' of github.com:Expensify/App int…
stitesExpensify 47a8a40
Style updates and simplifications
stitesExpensify a473d85
Don't show threads in search for now
grgia 702e6a6
Fix logic to always return bool
stitesExpensify e3b809e
Merge branch 'georgia-ThreadReportUI' of github.com:Expensify/App int…
stitesExpensify File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,12 +427,42 @@ function isPolicyExpenseChatAdmin(report, policies) { | |
return policyRole === CONST.POLICY.ROLE.ADMIN; | ||
} | ||
|
||
/** | ||
* Returns true if report has a parent and is therefore a Thread. | ||
* | ||
* @param {Object} report | ||
* @returns {Boolean} | ||
*/ | ||
function isThread(report) { | ||
return Boolean(report && report.parentReportID && report.parentReportActionID); | ||
} | ||
|
||
/** | ||
* Returns true if reportAction has a child. | ||
* | ||
* @param {Object} reportAction | ||
* @returns {Boolean} | ||
*/ | ||
function isThreadParent(reportAction) { | ||
return reportAction && reportAction.childReportID && reportAction.childReportID !== 0; | ||
} | ||
|
||
/** | ||
* Get either the policyName or domainName the chat is tied to | ||
* @param {Object} report | ||
* @returns {String} | ||
*/ | ||
function getChatRoomSubtitle(report) { | ||
if (isThread(report)) { | ||
if (!getChatType(report)) { | ||
return ''; | ||
} | ||
|
||
// If thread is not from a DM or group chat, the subtitle will follow the pattern 'Workspace Name • #roomName' | ||
const workspaceName = getPolicyName(report); | ||
const roomName = isChatRoom(report) ? lodashGet(report, 'displayName') : ''; | ||
return [workspaceName, roomName].join(' • '); | ||
} | ||
if (!isDefaultRoom(report) && !isUserCreatedPolicyRoom(report) && !isPolicyExpenseChat(report)) { | ||
return ''; | ||
} | ||
|
@@ -719,6 +749,27 @@ function getIcons(report, personalDetails, defaultIcon = null) { | |
result.source = Expensicons.DeletedRoomAvatar; | ||
return [result]; | ||
} | ||
if (isThread(report)) { | ||
const parentReport = lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`]); | ||
const parentReportAction = ReportActionsUtils.getParentReportAction(report); | ||
|
||
grgia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!parentReport) { | ||
stitesExpensify marked this conversation as resolved.
Show resolved
Hide resolved
|
||
result.source = Expensicons.ActiveRoomAvatar; | ||
return [result]; | ||
} | ||
|
||
if (getChatType(parentReport)) { | ||
result.source = getWorkspaceAvatar(parentReport); | ||
result.type = CONST.ICON_TYPE_WORKSPACE; | ||
result.name = getPolicyName(parentReport); | ||
return [result]; | ||
} | ||
|
||
const actorEmail = lodashGet(parentReportAction, 'actorEmail', ''); | ||
result.source = getAvatar(lodashGet(personalDetails, [actorEmail, 'avatar']), actorEmail); | ||
result.name = actorEmail; | ||
return [result]; | ||
} | ||
if (isDomainRoom(report)) { | ||
result.source = Expensicons.DomainRoomAvatar; | ||
return [result]; | ||
|
@@ -935,6 +986,11 @@ function getMoneyRequestReportName(report) { | |
*/ | ||
function getReportName(report) { | ||
let formattedName; | ||
if (isThread(report)) { | ||
const parentReportAction = ReportActionsUtils.getParentReportAction(report); | ||
const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' '); | ||
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage'); | ||
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. When the action is an Attachment, the title of the report will be |
||
} | ||
if (isChatRoom(report) || isTaskReport(report)) { | ||
formattedName = report.reportName; | ||
} | ||
|
@@ -1295,6 +1351,8 @@ function buildOptimisticIOUReportAction(type, amount, currency, comment, partici | |
* @param {String} oldPolicyName | ||
* @param {String} visibility | ||
* @param {String} notificationPreference | ||
* @param {String} parentReportActionID | ||
* @param {String} parentReportID | ||
* @returns {Object} | ||
*/ | ||
function buildOptimisticChatReport( | ||
|
@@ -1307,6 +1365,8 @@ function buildOptimisticChatReport( | |
oldPolicyName = '', | ||
visibility = undefined, | ||
notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, | ||
parentReportActionID, | ||
parentReportID, | ||
) { | ||
const currentTime = DateUtils.getDBTime(); | ||
return { | ||
|
@@ -1323,6 +1383,8 @@ function buildOptimisticChatReport( | |
notificationPreference, | ||
oldPolicyName, | ||
ownerEmail: ownerEmail || CONST.REPORT.OWNER_EMAIL_FAKE, | ||
parentReportActionID, | ||
parentReportID, | ||
participants: participantList, | ||
policyID, | ||
reportID: generateReportID(), | ||
|
@@ -1628,7 +1690,7 @@ function shouldReportBeInOptionList(report, reportIDFromRoute, isInGSDMode, curr | |
// Exclude reports that have no data because there wouldn't be anything to show in the option item. | ||
// This can happen if data is currently loading from the server or a report is in various stages of being created. | ||
// This can also happen for anyone accessing a public room or archived room for which they don't have access to the underlying policy. | ||
if (!report || !report.reportID || (_.isEmpty(report.participants) && !isPublicRoom(report) && !isArchivedRoom(report) && !isMoneyRequestReport(report))) { | ||
if (!report || !report.reportID || (_.isEmpty(report.participants) && !isThread(report) && !isPublicRoom(report) && !isArchivedRoom(report) && !isMoneyRequestReport(report))) { | ||
return false; | ||
} | ||
|
||
|
@@ -1678,15 +1740,15 @@ function shouldReportBeInOptionList(report, reportIDFromRoute, isInGSDMode, curr | |
} | ||
|
||
/** | ||
* Attempts to find a report in onyx with the provided list of participants | ||
* Attempts to find a report in onyx with the provided list of participants. Does not include threads | ||
* @param {Array} newParticipantList | ||
* @returns {Array|undefined} | ||
*/ | ||
function getChatByParticipants(newParticipantList) { | ||
newParticipantList.sort(); | ||
return _.find(allReports, (report) => { | ||
// If the report has been deleted, or there are no participants (like an empty #admins room) then skip it | ||
if (!report || !report.participants) { | ||
if (!report || !report.participants || isThread(report)) { | ||
return false; | ||
} | ||
|
||
|
@@ -2005,6 +2067,8 @@ export { | |
canRequestMoney, | ||
getWhisperDisplayNames, | ||
getWorkspaceAvatar, | ||
isThread, | ||
isThreadParent, | ||
shouldReportShowSubscript, | ||
isSettled, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it intentional to show workspace name and room name in thread?
As there's no way to see last thread message in LHN, the issue was reported here - #19447.
This only works in DM chat as subtitle not exist.
So I'd like to confirm if it's fine to use
optionItem.alternateText
here no matter thread or not.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.
@grgia bump ^
Here's design doc:
LHN:
Header: