How to use ternary operator or if else statement in typescript?

I am trying to return some value based on certain conditions.

 const getActions = React.useMemo(() =>
     (row: Row<Data>): RowAction[] | undefined => {
         const {original: { id, type, isComplete },} = row;
         const linkTo = type?.replace(':id',id);
         if (!mode && !linkTo) return undefined;
         const details: RowAction = {
             label: 'details',
             to: linkTo,
         };
         if (type !== 'something' && mode && !linkTo) {
             return undefined;
         }
         const btn: RowAction = {
             label: 'click here',
             onClick: () => somemethod,
         };
         if (!mode && canRead) {
             return [details];
         }
         if (mode && canRead && !canExecute) {
             return [details];
         }
         if (canRead && mode && canExecute) {
             return [details, btn];
         } 
         return undefined;
     },[canRead,canExecute,mode,somemethod]
 );

Above I am trying to return details or both details and button based on conditions:

-> if !mode and canRead then return details
-> if (!mode and canRead) or (mode and canRead and canExecute and !linkTo) or (mode 
   and !canRead and !canExecute and !linkTo) return undefined
-> if (mode and type !== 'something') return undefined
-> if (mode and canRead and canExecute) return btn and details
-> if (mode and canRead and !canExecute) return details

How can I write the above code better including all the above conditions?