Skip to content

Commit

Permalink
fix: create a variable for reportOrDefault to pass report as it is to…
Browse files Browse the repository at this point in the history
… child component
  • Loading branch information
abhinaybathina committed Sep 20, 2024
1 parent 185504b commit 69aba44
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pages/iou/request/step/withWritableReportOrNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,21 @@ export default function <TProps extends WithWritableReportOrNotFoundProps<MoneyR
// eslint-disable-next-line rulesdir/no-negated-variables
function WithWritableReportOrNotFound(props: Omit<TProps, keyof WithWritableReportOrNotFoundOnyxProps>, ref: ForwardedRef<TRef>) {
const {route} = props;
const [report = {reportID: ''}] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID ?? '-1'}`);
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID ?? '-1'}`);
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(report);
const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(reportOrDefault);

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

0 comments on commit 69aba44

Please sign in to comment.