Skip to content

Commit

Permalink
refactor: remove reportOrDraft variable and pass default value to can…
Browse files Browse the repository at this point in the history
…UserPerformWriteAction function only
  • Loading branch information
abhinaybathina committed Sep 23, 2024
1 parent f616bab commit edf4ee7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/pages/iou/request/step/withWritableReportOrNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ export default function <TProps extends WithWritableReportOrNotFoundProps<MoneyR
const [isLoadingApp = true] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const [reportDraft] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${route.params.reportID ?? '-1'}`);

const reportOrDefault = report ?? {reportID: ''};

const iouTypeParamIsInvalid = !Object.values(CONST.IOU.TYPE)
.filter((type) => shouldIncludeDeprecatedIOUType || (type !== CONST.IOU.TYPE.REQUEST && type !== CONST.IOU.TYPE.SEND))
.includes(route.params?.iouType);
const isEditing = 'action' in route.params && route.params?.action === CONST.IOU.ACTION.EDIT;

const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(reportOrDefault);
const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report ?? {reportID: ''});

useEffect(() => {
if (!!reportOrDefault?.reportID || !route.params.reportID || !!reportDraft || !isEditing) {
if (!!report?.reportID || !route.params.reportID || !!reportDraft || !isEditing) {
return;
}
ReportActions.openReport(route.params.reportID);
Expand Down

0 comments on commit edf4ee7

Please sign in to comment.