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

Feature/38774 expensify persona #41343

Merged
merged 25 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e343aa6
new persona added
burczu Apr 22, 2024
9a58f4f
using expensify persona only for odd account ids
burczu Apr 22, 2024
6da74e4
handling new system report type
burczu Apr 26, 2024
aaa3cd4
navigating to system chat at the end of the onboarding process added
burczu Apr 26, 2024
282490a
addional todo comment added
burczu Apr 26, 2024
f50eaaa
fix: resolve conflicts
koko57 Apr 30, 2024
0410d8f
fix: minor fix
koko57 Apr 30, 2024
179575f
fix: remove comment
koko57 Apr 30, 2024
9cba84a
fix: remove unnecessary condition
koko57 Apr 30, 2024
ba3aa46
fix: remove console log
koko57 Apr 30, 2024
5c2e6d2
fix: remove unnecessary change
koko57 May 2, 2024
36842b8
fix: apply requested changes
koko57 May 2, 2024
a6b6593
fix: lint
koko57 May 2, 2024
d858c04
Merge branch 'main' into feature/38774-expensify-persona-agata
burczu May 6, 2024
56cd07f
fix: resolve conflicts
koko57 Jun 4, 2024
8365690
fix: apply requested changes
koko57 Jun 4, 2024
717fe74
fix: lint
koko57 Jun 4, 2024
b765fe2
Merge branch 'main' into feature/38774-expensify-persona
koko57 Jun 10, 2024
e921c92
fix: show Persona chat in LHN
koko57 Jun 10, 2024
eab9f0b
fix: remove unnecessary comment
koko57 Jun 10, 2024
99b7398
fix: show only Expensify name for persona chat
koko57 Jun 10, 2024
0205df8
Merge branch 'main' into feature/38774-expensify-persona
koko57 Jun 11, 2024
08a87cd
fix: show persona chat only for onboarded by persona users
koko57 Jun 11, 2024
2015e43
Merge branch 'main' into feature/38774-expensify-persona
koko57 Jun 11, 2024
5dc7f6c
fix: lint and typecheck
koko57 Jun 11, 2024
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
3 changes: 2 additions & 1 deletion src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
!!optionItem.isThread ||
!!optionItem.isMoneyRequestReport ||
!!optionItem.isInvoiceReport ||
ReportUtils.isGroupChat(report)
ReportUtils.isGroupChat(report) ||
ReportUtils.isSystemChat(report)
}
/>
{isStatusVisible && (
Expand Down
1 change: 1 addition & 0 deletions src/libs/API/parameters/CompleteGuidedSetupParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {OnboardingPurposeType} from '@src/CONST';
type CompleteGuidedSetupParams = {
firstName: string;
lastName: string;
actorAccountID: number;
guidedSetupData: string;
engagementChoice: OnboardingPurposeType;
};
Expand Down
4 changes: 3 additions & 1 deletion src/libs/AccountUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please move this to the permissions file so that it is treated just like any of the other betas?

Copy link
Contributor

Choose a reason for hiding this comment

The 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};
12 changes: 12 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5437,6 +5437,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.
*/
Expand Down Expand Up @@ -7058,6 +7069,7 @@ export {
getRoomWelcomeMessage,
getRootParentReport,
getRouteFromLink,
getSystemChat,
getTaskAssigneeChatOnyxData,
getTransactionDetails,
getTransactionReportName,
Expand Down
7 changes: 7 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type PriorityMode from '@src/types/onyx/PriorityMode';
import type Report from '@src/types/onyx/Report';
import type ReportAction from '@src/types/onyx/ReportAction';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import AccountUtils from './AccountUtils';
import * as CollectionUtils from './CollectionUtils';
import {hasValidDraftComment} from './DraftCommentUtils';
import localeCompare from './LocaleCompare';
Expand Down Expand Up @@ -104,6 +105,12 @@ function getOrderedReportIDs(
return false;
}

const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number);

if (currentUserAccountID && AccountUtils.isAccountIDOddNumber(currentUserAccountID) && participantAccountIDs.includes(CONST.ACCOUNT_ID.NOTIFICATIONS)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey team, coming from #43782
This early return returns true (displays in LHN) for all chats that have CONST.ACCOUNT_ID.NOTIFICATIONS as a participant.
Domain chat room does have CONST.ACCOUNT_ID.NOTIFICATIONS as a participant, but doesn't need to be displayed in focus mode, since there are no unread messages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eVoloshchak Should I fix it or you're going with someone's proposal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koko57, I'm not entirely sure
On the one hand, this PR was deployed to prod 5 days ago, it's still in 7-day regression period, so it makes sense to fix it here
On the other hand, we've opened up the issue to contributors and have already received valid proposals

@twisterdotcom, could you weigh in on this please?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koko57 yes please, lets fix it, its still in the regression period

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar issue was detected where expensify chat showed up in focus mode even though there were no unread messages #43599. This was fixed in #44061

return true;
}

return ReportUtils.shouldReportBeInOptionList({
report,
currentReportId: currentReportId ?? '',
Expand Down
18 changes: 17 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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 {
Expand Down Expand Up @@ -2007,6 +2008,17 @@ function navigateToConciergeChat(shouldDismissModal = false, checkIfCurrentPageA
}
}

/**
* Navigates to the 1:1 system chat
*/
function navigateToSystemChat() {
const systemChatReport = ReportUtils.getSystemChat();

if (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);
Expand Down Expand Up @@ -3114,7 +3126,9 @@ 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, currentUserAccountID]);
const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {};
Expand Down Expand Up @@ -3403,6 +3417,7 @@ function completeOnboarding(
engagementChoice,
firstName,
lastName,
actorAccountID,
guidedSetupData: JSON.stringify(guidedSetupData),
};

Expand Down Expand Up @@ -3682,6 +3697,7 @@ export {
saveReportActionDraft,
deleteReportComment,
navigateToConciergeChat,
navigateToSystemChat,
addPolicyReport,
deleteReport,
navigateToConciergeChatAndDeleteReport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {FormOnyxValues} from '@components/Form/types';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import KeyboardAvoidingView from '@components/KeyboardAvoidingView';
import OfflineIndicator from '@components/OfflineIndicator';
import {useSession} from '@components/OnyxProvider';
import Text from '@components/Text';
import TextInput from '@components/TextInput';
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
Expand All @@ -16,6 +17,7 @@ import useLocalize from '@hooks/useLocalize';
import useOnboardingLayout from '@hooks/useOnboardingLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import AccountUtils from '@libs/AccountUtils';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as ValidationUtils from '@libs/ValidationUtils';
Expand All @@ -36,6 +38,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
const {shouldUseNarrowLayout} = useOnboardingLayout();
const {inputCallbackRef} = useAutoFocusInput();
const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false);
const {accountID} = useSession();

useDisableModalDismissOnEscape();

Expand Down Expand Up @@ -69,6 +72,8 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
// Otherwise stay on the chats screen.
if (isSmallScreenWidth) {
Navigation.navigate(ROUTES.HOME);
} else if (AccountUtils.isAccountIDOddNumber(accountID ?? 0)) {
Report.navigateToSystemChat();
} else {
Report.navigateToConciergeChat();
}
Expand All @@ -79,7 +84,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
Navigation.navigate(ROUTES.WELCOME_VIDEO_ROOT);
}, variables.welcomeVideoDelay);
},
[isSmallScreenWidth, onboardingPurposeSelected, onboardingAdminsChatReportID],
[isSmallScreenWidth, onboardingPurposeSelected, onboardingAdminsChatReportID, accountID],
);

const validate = (values: FormOnyxValues<'onboardingPersonalDetailsForm'>) => {
Expand Down
Loading