-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix unavailable workspace is shown when share track expense with accountant #73406
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
Changes from all commits
8162148
09ad23b
19e8c7f
97ec995
8d4bdd5
38c65b3
f2a7763
0f427cc
4de4ff4
43e371d
89d5b5e
128f303
1b42bc8
33dba3e
731f933
25f9c1f
1550f94
744ddb8
5e4c6d9
13a73a7
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -950,7 +950,7 @@ | |||||||||||||||||
| const parsedReportActionMessageCache: Record<string, string> = {}; | ||||||||||||||||||
|
|
||||||||||||||||||
| let conciergeReportID: OnyxEntry<string>; | ||||||||||||||||||
| Onyx.connect({ | ||||||||||||||||||
| key: ONYXKEYS.CONCIERGE_REPORT_ID, | ||||||||||||||||||
| callback: (value) => { | ||||||||||||||||||
| conciergeReportID = value; | ||||||||||||||||||
|
|
@@ -1001,6 +1001,13 @@ | |||||||||||||||||
| callback: (value) => (allPolicies = value), | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| let allPolicyDrafts: OnyxCollection<Policy>; | ||||||||||||||||||
| Onyx.connectWithoutView({ | ||||||||||||||||||
| key: ONYXKEYS.COLLECTION.POLICY_DRAFTS, | ||||||||||||||||||
| waitForCollectionCallback: true, | ||||||||||||||||||
| callback: (value) => (allPolicyDrafts = value), | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| let allReports: OnyxCollection<Report>; | ||||||||||||||||||
| let reportsByPolicyID: ReportByPolicyMap; | ||||||||||||||||||
| Onyx.connect({ | ||||||||||||||||||
|
|
@@ -1208,10 +1215,10 @@ | |||||||||||||||||
| /** | ||||||||||||||||||
| * Get the report or draft report given a reportID | ||||||||||||||||||
| */ | ||||||||||||||||||
| function getReportOrDraftReport(reportID: string | undefined, searchReports?: Report[], fallbackReport?: Report): OnyxEntry<Report> { | ||||||||||||||||||
| function getReportOrDraftReport(reportID: string | undefined, searchReports?: Report[], fallbackReport?: Report, reportDrafts?: OnyxCollection<Report>): OnyxEntry<Report> { | ||||||||||||||||||
| const searchReport = searchReports?.find((report) => report.reportID === reportID); | ||||||||||||||||||
| const onyxReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; | ||||||||||||||||||
| return searchReport ?? onyxReport ?? allReportsDraft?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${reportID}`] ?? fallbackReport; | ||||||||||||||||||
| return searchReport ?? onyxReport ?? (reportDrafts ?? allReportsDraft)?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${reportID}`] ?? fallbackReport; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Contributor
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. In case you use
Suggested change
Contributor
Author
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. Which part? I don't see any lint warning around here.
Contributor
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. Ah my bad, I was running There's still errors in tests/unit/ReportUtilsTest.ts though
Contributor
Author
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 |
||||||||||||||||||
|
|
||||||||||||||||||
| function reportTransactionsSelector(transactions: OnyxCollection<Transaction>, reportID: string | undefined): Transaction[] { | ||||||||||||||||||
|
|
@@ -4187,10 +4194,11 @@ | |||||||||||||||||
| return {}; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const policyReportFields = Object.entries(allPolicies ?? {}).find(([key]) => key.replace(ONYXKEYS.COLLECTION.POLICY, '') === policyID); | ||||||||||||||||||
| const fieldList = policyReportFields?.[1]?.fieldList; | ||||||||||||||||||
| const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]; | ||||||||||||||||||
| const policyDraft = allPolicyDrafts?.[`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`]; | ||||||||||||||||||
| const fieldList = (policy ?? policyDraft)?.fieldList; | ||||||||||||||||||
|
Contributor
Author
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. We need to get the report field list on the policy draft too. I simplify this to getting the policy object by directly indexing the object instead of iterating the entires one by one. |
||||||||||||||||||
|
|
||||||||||||||||||
| if (!policyReportFields || !fieldList) { | ||||||||||||||||||
| if ((!policy && !policyDraft) || !fieldList) { | ||||||||||||||||||
| return {}; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -6570,12 +6578,14 @@ | |||||||||||||||||
| // The amount for Expense reports are stored as negative value in the database | ||||||||||||||||||
| const storedTotal = total * -1; | ||||||||||||||||||
| const storedNonReimbursableTotal = nonReimbursableTotal * -1; | ||||||||||||||||||
| const report = chatReportID ? getReport(chatReportID, allReports) : undefined; | ||||||||||||||||||
| const report = chatReportID ? getReportOrDraftReport(chatReportID) : undefined; | ||||||||||||||||||
| const policyName = getPolicyName({report}); | ||||||||||||||||||
| const formattedTotal = convertToDisplayString(storedTotal, currency); | ||||||||||||||||||
| // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 | ||||||||||||||||||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||||||||||||||||||
| const policy = getPolicy(policyID); | ||||||||||||||||||
| const policyReal = getPolicy(policyID); | ||||||||||||||||||
| const policyDraft = allPolicyDrafts?.[`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`]; | ||||||||||||||||||
| const policy = policyReal ?? policyDraft; | ||||||||||||||||||
|
|
||||||||||||||||||
| const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -6611,7 +6621,7 @@ | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const titleReportField = getTitleReportField(getReportFieldsByPolicyID(policyID) ?? {}); | ||||||||||||||||||
| if (!!titleReportField && isPaidGroupPolicyExpenseReport(expenseReport)) { | ||||||||||||||||||
| if (!!titleReportField && isGroupPolicy(policy?.type ?? '')) { | ||||||||||||||||||
|
Contributor
Author
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. Even though we get the policy field list from
Lines 1684 to 1687 in a0f0159
Lines 1662 to 1665 in a0f0159
So, to simplify this, I just use |
||||||||||||||||||
| expenseReport.reportName = populateOptimisticReportFormula(titleReportField.defaultValue, expenseReport, policy); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2571,6 +2571,17 @@ function createDraftWorkspace( | |
| disabledFields: {defaultBillable: true, reimbursable: false}, | ||
| requiresCategory: true, | ||
| defaultReimbursable: true, | ||
| fieldList: { | ||
| [CONST.POLICY.FIELDS.FIELD_LIST_TITLE]: { | ||
| defaultValue: CONST.POLICY.DEFAULT_REPORT_NAME_PATTERN, | ||
| pendingFields: {defaultValue: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, deletable: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}, | ||
| type: CONST.POLICY.DEFAULT_FIELD_LIST_TYPE, | ||
| target: CONST.POLICY.DEFAULT_FIELD_LIST_TARGET, | ||
| name: CONST.POLICY.DEFAULT_FIELD_LIST_NAME, | ||
| fieldID: CONST.POLICY.FIELDS.FIELD_LIST_TITLE, | ||
| deletable: true, | ||
| }, | ||
| }, | ||
|
Contributor
Author
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. We need to optimistically set the field list. |
||
| }, | ||
| }, | ||
| { | ||
|
|
||
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.
I think we still need to avoid using Onyx.connect. Is this the only way to handle
getReportOrDraftReport. Can we just rely on the passing params instead?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.
It's not for
getReportOrDraftReport. It's forbuildOptimisticExpenseReportandgetReportFieldsByPolicyID. Both functions don't affect rendering, so I think it's fine to useconnectWithoutView.