-
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
Feature/38774 expensify persona #41343
Changes from 10 commits
e343aa6
9a58f4f
6da74e4
aaa3cd4
282490a
f50eaaa
0410d8f
179575f
9cba84a
ba3aa46
5c2e6d2
36842b8
a6b6593
d858c04
56cd07f
8365690
717fe74
b765fe2
e921c92
eab9f0b
99b7398
0205df8
08a87cd
2015e43
5dc7f6c
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 |
---|---|---|
|
@@ -5,4 +5,6 @@ import type {Account} from '@src/types/onyx'; | |
const isValidateCodeFormSubmitting = (account: OnyxEntry<Account>) => | ||
!!account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); | ||
|
||
export default {isValidateCodeFormSubmitting}; | ||
const isAccountIDOddNumber = (accountID: number) => accountID % 2 === 1; | ||
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. Can we please move this to the 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. Fair, I think we were not looking at this as a beta, but I can see where you are coming from. @koko57 do you think you could move this around to permissions file? |
||
|
||
export default {isValidateCodeFormSubmitting, isAccountIDOddNumber}; |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -4974,7 +4974,6 @@ function shouldReportBeInOptionList({ | |||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||||
report?.isHidden || | ||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||||
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.
Suggested change
|
||||
report?.participantAccountIDs?.includes(CONST.ACCOUNT_ID.NOTIFICATIONS) || | ||||
(report?.participantAccountIDs?.length === 0 && | ||||
!isChatThread(report) && | ||||
!isPublicRoom(report) && | ||||
|
@@ -5061,6 +5060,17 @@ function shouldReportBeInOptionList({ | |||
return true; | ||||
} | ||||
|
||||
/** | ||||
* Returns the system report from the list of reports. | ||||
*/ | ||||
function getSystemChat(): OnyxEntry<Report> { | ||||
if (!allReports) { | ||||
return null; | ||||
} | ||||
|
||||
return Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) ?? null; | ||||
} | ||||
|
||||
/** | ||||
* Attempts to find a report in onyx with the provided list of participants. Does not include threads, task, expense, room, and policy expense chat. | ||||
*/ | ||||
|
@@ -6544,6 +6554,7 @@ export { | |||
getRoomWelcomeMessage, | ||||
getRootParentReport, | ||||
getRouteFromLink, | ||||
getSystemChat, | ||||
getTaskAssigneeChatOnyxData, | ||||
getTransactionDetails, | ||||
getTransactionReportName, | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import localeCompare from './LocaleCompare'; | |
import * as LocalePhoneNumber from './LocalePhoneNumber'; | ||
import * as Localize from './Localize'; | ||
import * as OptionsListUtils from './OptionsListUtils'; | ||
import * as PersonalDetailsUtils from './PersonalDetailsUtils'; | ||
import * as ReportActionsUtils from './ReportActionsUtils'; | ||
import * as ReportUtils from './ReportUtils'; | ||
import * as TaskUtils from './TaskUtils'; | ||
|
@@ -244,6 +245,11 @@ function getOptionData({ | |
participantAccountIDs = [report.ownerAccountID ?? 0]; | ||
} | ||
|
||
// TODO: this is added for the testing purposes only - should be removed once participants list of the system report is filled | ||
if (report.chatType === CONST.REPORT.CHAT_TYPE.SYSTEM) { | ||
participantAccountIDs = [report.ownerAccountID ?? 0, ...PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.NOTIFICATIONS])]; | ||
} | ||
|
||
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. Are we good to remove this block of code? |
||
const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)) as PersonalDetails[]; | ||
const personalDetail = participantPersonalDetailList[0] ?? {}; | ||
const hasErrors = Object.keys(result.allReportErrors ?? {}).length !== 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import Onyx from 'react-native-onyx'; | |
import type {PartialDeep, ValueOf} from 'type-fest'; | ||
import type {Emoji} from '@assets/emojis/types'; | ||
import type {FileObject} from '@components/AttachmentModal'; | ||
import AccountUtils from '@libs/AccountUtils'; | ||
import * as ActiveClientManager from '@libs/ActiveClientManager'; | ||
import * as API from '@libs/API'; | ||
import type { | ||
|
@@ -350,7 +351,10 @@ function subscribeToReportTypingEvents(reportID: string) { | |
delete typingWatchTimers[reportUserIdentifier]; | ||
}, 1500); | ||
}).catch((error) => { | ||
Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', {errorType: error.type, pusherChannelName}); | ||
Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', { | ||
errorType: error.type, | ||
pusherChannelName, | ||
}); | ||
}); | ||
} | ||
|
||
|
@@ -381,7 +385,10 @@ function subscribeToReportLeavingEvents(reportID: string) { | |
|
||
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM}${reportID}`, true); | ||
}).catch((error) => { | ||
Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', {errorType: error.type, pusherChannelName}); | ||
Log.hmmm('[Report] Failed to initially subscribe to Pusher channel', { | ||
errorType: error.type, | ||
pusherChannelName, | ||
}); | ||
}); | ||
} | ||
|
||
|
@@ -870,7 +877,11 @@ function openReport( | |
|
||
if (isFromDeepLink) { | ||
// eslint-disable-next-line rulesdir/no-api-side-effects-method | ||
API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_REPORT, parameters, {optimisticData, successData, failureData}).finally(() => { | ||
API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_REPORT, parameters, { | ||
optimisticData, | ||
successData, | ||
failureData, | ||
}).finally(() => { | ||
Onyx.set(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, false); | ||
}); | ||
} else { | ||
|
@@ -1850,7 +1861,10 @@ function updateDescription(reportID: string, previousValue: string, newValue: st | |
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, | ||
value: {description: parsedDescription, pendingFields: {description: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}, | ||
value: { | ||
description: parsedDescription, | ||
pendingFields: {description: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, | ||
}, | ||
}, | ||
]; | ||
const failureData: OnyxUpdate[] = [ | ||
|
@@ -1925,6 +1939,17 @@ function navigateToConciergeChat(shouldDismissModal = false, checkIfCurrentPageA | |
} | ||
} | ||
|
||
/** | ||
* Navigates to the 1:1 system chat | ||
*/ | ||
function navigateToSystemChat() { | ||
const systemChatReport = ReportUtils.getSystemChat(); | ||
|
||
if (systemChatReport && systemChatReport.reportID) { | ||
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(systemChatReport.reportID)); | ||
} | ||
} | ||
|
||
/** Add a policy report (workspace room) optimistically and navigate to it. */ | ||
function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { | ||
const createdReportAction = ReportUtils.buildOptimisticCreatedReportAction(CONST.POLICY.OWNER_EMAIL_FAKE); | ||
|
@@ -2202,7 +2227,10 @@ function shouldShowReportActionNotification(reportID: string, action: ReportActi | |
|
||
// If this notification was delayed and the user saw the message already, don't show it | ||
if (action && report?.lastReadTime && report.lastReadTime >= action.created) { | ||
Log.info(`${tag} No notification because the comment was already read`, false, {created: action.created, lastReadTime: report.lastReadTime}); | ||
Log.info(`${tag} No notification because the comment was already read`, false, { | ||
created: action.created, | ||
lastReadTime: report.lastReadTime, | ||
}); | ||
return false; | ||
} | ||
|
||
|
@@ -2230,7 +2258,10 @@ function showReportActionNotification(reportID: string, reportAction: ReportActi | |
|
||
const report = allReports?.[reportID] ?? null; | ||
if (!report) { | ||
Log.hmmm("[LocalNotification] couldn't show report action notification because the report wasn't found", {reportID, reportActionID: reportAction.reportActionID}); | ||
Log.hmmm("[LocalNotification] couldn't show report action notification because the report wasn't found", { | ||
reportID, | ||
reportActionID: reportAction.reportActionID, | ||
}); | ||
return; | ||
} | ||
|
||
|
@@ -3011,9 +3042,12 @@ function completeOnboarding( | |
}, | ||
adminsChatReportID?: string, | ||
) { | ||
const targetEmail = CONST.EMAIL.CONCIERGE; | ||
const isAccountIDOdd = AccountUtils.isAccountIDOddNumber(currentUserAccountID ?? 0); | ||
const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE; | ||
|
||
const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; | ||
koko57 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID]); | ||
// TODO: using getSystemChat is rather not necessary if we could have participants list filled correctly | ||
const targetChatReport = isAccountIDOdd ? ReportUtils.getSystemChat() : ReportUtils.getChatByParticipants([actorAccountID]); | ||
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. Is this TODO within the scope of this PR? |
||
const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; | ||
|
||
// Mention message | ||
|
@@ -3713,6 +3747,7 @@ export { | |
saveReportActionDraft, | ||
deleteReportComment, | ||
navigateToConciergeChat, | ||
navigateToSystemChat, | ||
addPolicyReport, | ||
deleteReport, | ||
navigateToConciergeChatAndDeleteReport, | ||
|
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.
NAB - this could be made a bit more generic as
NumberUtils.isOdd(value: number)