-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Task Share Destination Fixes #24019
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
Task Share Destination Fixes #24019
Changes from 12 commits
a262192
8c98c9a
b670ed5
c3591e5
603b305
3dd5301
157f56d
b778073
e938e74
1308dfd
a21355e
c703f7d
6bac6dc
de39deb
b9cc192
ce779cc
18daf91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,6 +460,17 @@ function isConciergeChatReport(report) { | |
return lodashGet(report, 'participantAccountIDs', []).length === 1 && Number(report.participantAccountIDs[0]) === CONST.ACCOUNT_ID.CONCIERGE && !isChatThread(report); | ||
} | ||
|
||
/** | ||
* Returns true if we can share a task in this report | ||
* @param {Object} report | ||
* @returns {Boolean} | ||
*/ | ||
|
||
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. Added space 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. Removed, sorry |
||
function canShareTaskInReport(report) { | ||
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. This can be general function, not tied to task. 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. Done, thanks 🙏 |
||
const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), currentUserAccountID); | ||
return lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID)); | ||
} | ||
|
||
/** | ||
* Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of accountIDs | ||
* by cross-referencing the accountIDs with personalDetails. | ||
|
@@ -2834,6 +2845,7 @@ export { | |
findLastAccessedReport, | ||
canEditReportAction, | ||
canFlagReportAction, | ||
canShareTaskInReport, | ||
shouldShowFlagComment, | ||
canDeleteReportAction, | ||
canLeaveRoom, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import {View} from 'react-native'; | |
import PropTypes from 'prop-types'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import OptionsSelector from '../../components/OptionsSelector'; | ||
|
||
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. Another space added here 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. @thienlnam sorry for the inconvenience, removed some code after the adjustments with the new functions. I thought |
||
import * as OptionsListUtils from '../../libs/OptionsListUtils'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import styles from '../../styles/styles'; | ||
|
@@ -45,35 +46,27 @@ function TaskShareDestinationSelectorModal(props) { | |
const [searchValue, setSearchValue] = useState(''); | ||
const [headerMessage, setHeaderMessage] = useState(''); | ||
const [filteredRecentReports, setFilteredRecentReports] = useState([]); | ||
const [filteredPersonalDetails, setFilteredPersonalDetails] = useState([]); | ||
const [filteredUserToInvite, setFilteredUserToInvite] = useState(null); | ||
|
||
const filteredReports = useMemo(() => { | ||
const reports = {}; | ||
_.keys(props.reports).forEach((reportKey) => { | ||
if (!ReportUtils.isAllowedToComment(props.reports[reportKey])) { | ||
if ( | ||
!ReportUtils.isAllowedToComment(props.reports[reportKey]) || | ||
ReportUtils.isArchivedRoom(props.reports[reportKey]) || | ||
ReportUtils.canShareTaskInReport(props.reports[reportKey]) | ||
) { | ||
return; | ||
} | ||
reports[reportKey] = props.reports[reportKey]; | ||
}); | ||
return reports; | ||
}, [props.reports]); | ||
const updateOptions = useCallback(() => { | ||
const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getShareDestinationOptions( | ||
filteredReports, | ||
props.personalDetails, | ||
props.betas, | ||
searchValue.trim(), | ||
[], | ||
CONST.EXPENSIFY_EMAILS, | ||
true, | ||
); | ||
|
||
setHeaderMessage(OptionsListUtils.getHeaderMessage(recentReports?.length + personalDetails?.length !== 0, Boolean(userToInvite), searchValue)); | ||
|
||
setFilteredUserToInvite(userToInvite); | ||
const {recentReports} = OptionsListUtils.getShareDestinationOptions(filteredReports, props.personalDetails, props.betas, searchValue.trim(), [], CONST.EXPENSIFY_EMAILS, true); | ||
|
||
setHeaderMessage(OptionsListUtils.getHeaderMessage(recentReports?.length !== 0, false, searchValue)); | ||
|
||
setFilteredRecentReports(recentReports); | ||
setFilteredPersonalDetails(personalDetails); | ||
}, [props, searchValue, filteredReports]); | ||
|
||
useEffect(() => { | ||
|
@@ -101,23 +94,6 @@ function TaskShareDestinationSelectorModal(props) { | |
indexOffset += filteredRecentReports?.length; | ||
} | ||
|
||
if (filteredPersonalDetails?.length > 0) { | ||
sections.push({ | ||
data: filteredPersonalDetails, | ||
shouldShow: true, | ||
indexOffset, | ||
}); | ||
indexOffset += filteredRecentReports?.length; | ||
} | ||
|
||
if (filteredUserToInvite) { | ||
sections.push({ | ||
data: [filteredUserToInvite], | ||
shouldShow: true, | ||
indexOffset, | ||
}); | ||
} | ||
|
||
return sections; | ||
}; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.