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

[Manual Requests] Create thread for Manual Request when opening IOUPreview #18760

Merged
merged 26 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
202122a
create method to find if a thread exists or not
bondydaa May 11, 2023
fa1b3dc
add rough sketch of what needs to happen to create a thread on demand
bondydaa May 11, 2023
e30b603
fixing merge conflict
bondydaa May 12, 2023
a5e043e
rename method and update to return the report object for a thread
bondydaa May 12, 2023
94c9125
allow the passing of a parentReportActionID so we can create threads
bondydaa May 12, 2023
94c19d6
generate report optimistically and pass parentReportActionID to creat…
bondydaa May 12, 2023
b2c926f
Merge branch 'main' of github.com:Expensify/App into bondy-thread-man…
bondydaa May 12, 2023
6e3bf2c
appease linter
bondydaa May 12, 2023
b4a991b
appease linter and import full lib
bondydaa May 12, 2023
c0e2430
we dont need to prefilter the user making the request out since auth …
bondydaa May 12, 2023
4cfefbb
use amount not payee in report name
bondydaa May 12, 2023
9d518ba
fixing jsdocs and comment
bondydaa May 12, 2023
f83e240
use proper prop
bondydaa May 12, 2023
03f8c6f
Merge main and resolve conflicts
mountiny May 13, 2023
dfc4e79
Fix linter
mountiny May 13, 2023
33afd33
Merge branch 'main' into bondy-thread-manual-requests
mountiny May 14, 2023
6e6eb06
Merge branch 'vit-ensureDeleteShowsAsText' into bondy-thread-manual-r…
mountiny May 14, 2023
35c3c79
Ensure threads are created optimistically
mountiny May 14, 2023
22f9a4a
Add the childReportID to the report action so we do not create multip…
mountiny May 14, 2023
bcb6855
Merge branch 'main' into bondy-thread-manual-requests
mountiny May 14, 2023
3ec51b5
Remove unsused method
mountiny May 14, 2023
9acde61
Merge branch 'main' into bondy-thread-manual-requests
mountiny May 15, 2023
e9d4c4a
Access property safely
mountiny May 15, 2023
df1462a
Update spanish translation
mountiny May 15, 2023
42db583
Fix lint
mountiny May 15, 2023
e800564
Merge branch 'main' into bondy-thread-manual-requests
mountiny May 15, 2023
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
5 changes: 5 additions & 0 deletions src/components/ReportActionItem/IOUAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Navigation from '../../libs/Navigation/Navigation';
import ROUTES from '../../ROUTES';
import styles from '../../styles/styles';
import * as IOUUtils from '../../libs/IOUUtils';
import {doesThreadExistForReportActionID} from '../../libs/ReportUtils';

const propTypes = {
/** All the data of the action */
Expand Down Expand Up @@ -71,6 +72,10 @@ const defaultProps = {
const IOUAction = (props) => {
const hasMultipleParticipants = props.chatReport.participants.length > 1;
const onIOUPreviewPressed = () => {
if (!doesThreadExistForReportActionID(props.action.reportActionID)) {
// optimistically create reportID
// pass it along to OpenReport since that is build to create a thread when needed, not sure what to do about the navigation stuff below...
mountiny marked this conversation as resolved.
Show resolved Hide resolved
}
if (hasMultipleParticipants) {
Navigation.navigate(ROUTES.getReportParticipantsRoute(props.chatReportID));
} else {
Expand Down
19 changes: 19 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,24 @@ function getWhisperDisplayNames(participants) {
return _.map(participants, (login) => getDisplayNameForParticipant(login, !isWhisperOnlyVisibleToCurrentUSer)).join(', ');
}

/**
* Used to determine if a thread exists already or not for a given reportActionID
mountiny marked this conversation as resolved.
Show resolved Hide resolved
*
* @param {String}
* @returns {Boolean}
*/
function doesThreadExistForReportActionID(reportActionID) {
const thread = _.find(allReports, (report) => {
if (!report.parentReportActionID) {
return false;
}

return report.parentReportActionID === reportActionID;
});

return !_.isEmpty(thread);
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand Down Expand Up @@ -1925,4 +1943,5 @@ export {
canRequestMoney,
getWhisperDisplayNames,
getWorkspaceAvatar,
doesThreadExistForReportActionID,
};